Skip to content

Commit

Permalink
Use uppercase for constants
Browse files Browse the repository at this point in the history
  • Loading branch information
hagenw committed May 16, 2024
1 parent fc4f23d commit f0141af
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions sphinxcontrib/katex.py
Original file line number Diff line number Diff line change
Expand Up @@ -356,16 +356,16 @@ class KaTeXError(Exception):
class KaTeXServer:
"""Manages and communicates with an instance of the render server."""

length_struct = struct.Struct("<i")
"""Message length (32-bit little-endian integer)."""
LENGTH_STRUCT = struct.Struct("<i")
"""Message length for 32-bit little-endian integer."""

katex_path = None
"""Path to KaTeX javascript file."""

katex_server = None
"""Global instance of KaTeX server."""

stop_timeout = 0.1
STOP_TIMEOUT = 0.1
"""Wait time for the server to stop in seconds."""

@classmethod
Expand Down Expand Up @@ -513,7 +513,7 @@ def terminate(self):
self.sock.close()
try:
self.process.terminate()
self.process.wait(timeout=self.stop_timeout)
self.process.wait(timeout=self.STOP_TIMEOUT)
except TimeoutExpired:
self.process.kill()
shutil.rmtree(self.rundir)
Expand All @@ -530,12 +530,12 @@ def render(self, request, timeout=None):
# Send the request
request_bytes = json.dumps(request).encode("utf-8")
length = len(request_bytes)
self.sock.sendall(self.length_struct.pack(length))
self.sock.sendall(self.LENGTH_STRUCT.pack(length))
self.sock.sendall(request_bytes)

# Read the amount of bytes we are about to receive
size = self.sock.recv(self.length_struct.size)
length = self.length_struct.unpack(size)[0]
size = self.sock.recv(self.LENGTH_STRUCT.size)
length = self.LENGTH_STRUCT.unpack(size)[0]

# Ensure that the buffer is large enough
if len(self.buffer) < length:
Expand Down

0 comments on commit f0141af

Please sign in to comment.