Skip to content

Commit

Permalink
Check if pools are alive
Browse files Browse the repository at this point in the history
  • Loading branch information
borzunov committed Dec 12, 2022
1 parent 83d9493 commit 1d31dd4
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/petals/server/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,8 +235,8 @@ def run(self):
if self.stop.wait(timeout):
return

if not self.module_container.handlers_alive:
logger.warning("One of connection handlers crashed, restarting the server")
if not self.module_container.is_healthy():
logger.warning("One of subprocesses crashed, restarting the server")
break

if self._should_choose_other_blocks():
Expand Down Expand Up @@ -470,9 +470,11 @@ def ready(self) -> mp.synchronize.Event:
"""
return self.runtime.ready # mp.Event that is true if self is ready to process batches

@property
def handlers_alive(self) -> bool:
return all(handler.is_alive() for handler in self.conn_handlers)
def is_healthy(self) -> bool:
return (
all(handler.is_alive() for handler in self.conn_handlers) and
all(pool.is_alive() for pool in self.runtime.pools)
)

def shutdown(self):
"""
Expand Down

0 comments on commit 1d31dd4

Please sign in to comment.