7373DEBUG_MODE = False
7474
7575
76- def set_debug_mode (mode : bool = True ):
76+ def set_debug_mode (mode : bool = True ):
7777 """Set the debug mode."""
7878 global DEBUG_MODE
7979 DEBUG_MODE = mode
8080
8181
82- def set_wait_factor (factor : float ):
82+ def set_wait_factor (factor : float ):
8383 """Set the wait factor."""
8484 global RLIMIT_SECONDS
8585 global RESPONSE_TIMEOUT
@@ -93,7 +93,7 @@ def __init__(
9393 self ,
9494 cl : str | list [str ] | None = "ada_language_server" ,
9595 working_dir : str = "." ,
96- env : dict | None = None
96+ env : dict | None = None ,
9797 ):
9898 """Launch an LSP server and provide a way to send messages to it.
9999 cl is the command line to launch the LSP server.
@@ -119,8 +119,9 @@ def __init__(
119119 self .wd = working_dir
120120
121121 # Kill the server when we reach this time
122- self .kill_me_at = time .time () + RLIMIT_SECONDS * (
123- 1 + os .environ .get ("ALS_WAIT_FACTOR" , 0 ))
122+ self .kill_me_at = time .time () + int (
123+ RLIMIT_SECONDS * os .environ .get ("ALS_WAIT_FACTOR" , 1.0 )
124+ )
124125
125126 # This contains either None or a timestamp. If a timestamp,
126127 # then the process should be killed after 2 seconds after this.
@@ -148,7 +149,6 @@ def __init__(
148149 if DEBUG_MODE :
149150 self .debug_here ()
150151
151-
152152 def kill_task (self ):
153153 while True :
154154 time .sleep (0.2 )
@@ -178,7 +178,7 @@ def receive_task(self):
178178 break
179179 if not header .startswith ("Content-Length:" ):
180180 continue
181- length = int (header [len ("Content-Length:" ):])
181+ length = int (header [len ("Content-Length:" ) :])
182182
183183 # TODO: Add support for "Content-Type" header
184184
@@ -199,9 +199,7 @@ def receive_task(self):
199199
200200 time .sleep (0.01 )
201201
202- def send (
203- self , message : LSPMessage , expect_response = True
204- ) -> LSPResponse | None :
202+ def send (self , message : LSPMessage , expect_response = True ) -> LSPResponse | None :
205203 """Send a message to the LSP server.
206204 If expect_response is True, wait for a response for at most timeout seconds.
207205 Return the response if any, or None if no response
@@ -257,12 +255,13 @@ def shutdown(self):
257255 # If errors were found, capture a replay file.
258256 # Compute the replay dir based on this file
259257 replay_dir = os .path .join (
260- os .path .dirname (os .path .dirname (os .path .abspath (__file__ ))),
261- "replays"
258+ os .path .dirname (os .path .dirname (os .path .abspath (__file__ ))), "replays"
262259 )
263260 # Create the directory if it doesn't exist
264261 os .makedirs (replay_dir , exist_ok = True )
265- replay_file = os .path .join (replay_dir , os .path .basename (self .wd ) + "_replay.txt" )
262+ replay_file = os .path .join (
263+ replay_dir , os .path .basename (self .wd ) + "_replay.txt"
264+ )
266265 self .errors .append (f"Replay file written to { replay_file } " )
267266
268267 # Write a "replay.txt" replay file
0 commit comments