Skip to content

Commit 79126e6

Browse files
committed
update comments
Signed-off-by: pandyamarut <pandyamarut@gmail.com>
1 parent afcf801 commit 79126e6

2 files changed

Lines changed: 17 additions & 2 deletions

File tree

runpod/serverless/modules/rp_scale.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,15 @@ def start(self):
176176
asyncio.run(self.run())
177177

178178
def handle_shutdown(self, signum, frame):
179+
"""
180+
Called when the worker is signalled to shut down.
181+
This function is called when the worker receives a signal to shut down, such as
182+
SIGTERM or SIGINT. It sets the shutdown event, which will cause the worker to
183+
exit its main loop and shut down gracefully.
184+
Args:
185+
signum: The signal number that was received.
186+
frame: The current stack frame.
187+
"""
179188
log.debug(f"Received shutdown signal: {signum}.")
180189
self.kill_worker()
181190

@@ -197,9 +206,15 @@ async def run(self):
197206
raise
198207

199208
def is_alive(self):
209+
"""
210+
Return whether the worker is alive or not.
211+
"""
200212
return not self._shutdown_event.is_set()
201213

202214
def kill_worker(self):
215+
"""
216+
Whether to kill the worker.
217+
"""
203218
log.debug("Kill worker.")
204219
self._shutdown_event.set()
205220

runpod/serverless/modules/worker_state.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ def __str__(self) -> str:
5858

5959
class JobsProgress:
6060
"""
61-
OPTIMIZED: Track jobs in progress with O(1) operations using threading.Lock
61+
Track jobs in progress with min operations using threading.Lock
6262
instead of multiprocessing.Manager for better performance.
6363
"""
6464

@@ -91,7 +91,7 @@ def clear(self) -> None:
9191

9292
def add(self, element: Any):
9393
"""
94-
OPTIMIZED: O(1) addition of jobs using dict
94+
addition of jobs using dict
9595
"""
9696
if isinstance(element, str):
9797
job_id = element

0 commit comments

Comments
 (0)