Skip to content

Commit

Permalink
Fixed a race condition issue during the server start. (#2235)
Browse files Browse the repository at this point in the history
Co-authored-by: Chester Chen <[email protected]>
  • Loading branch information
yhwen and chesterxgchen authored Dec 21, 2023
1 parent 2a5b233 commit d67baf4
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
2 changes: 2 additions & 0 deletions nvflare/private/fed/app/deployer/server_deployer.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
from nvflare.private.fed.server.job_runner import JobRunner
from nvflare.private.fed.server.run_manager import RunManager
from nvflare.private.fed.server.server_cmd_modules import ServerCommandModules
from nvflare.private.fed.server.server_status import ServerStatus


class ServerDeployer:
Expand Down Expand Up @@ -121,6 +122,7 @@ def deploy(self, args):
services.engine.fire_event(EventType.SYSTEM_BOOTSTRAP, fl_ctx)

threading.Thread(target=self._start_job_runner, args=[job_runner, fl_ctx]).start()
services.status = ServerStatus.STARTED

services.engine.fire_event(EventType.SYSTEM_START, fl_ctx)
print("deployed FL server trainer.")
Expand Down
3 changes: 3 additions & 0 deletions nvflare/private/fed/server/fed_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -779,6 +779,9 @@ def _init_agent(self, args=None):
return self.overseer_agent

def _check_server_state(self, overseer_agent):
if self.status != ServerStatus.STARTED:
return

if overseer_agent.is_shutdown():
self.engine.shutdown_server()
return
Expand Down

0 comments on commit d67baf4

Please sign in to comment.