Skip to content

Commit a900f90

Browse files
authored
Merge pull request openwallet-foundation#1960 from frostyfrog/frosty/shutdown-hang-fix
fix: Safely shutdown when root_profile uninitialized
2 parents e62d5ba + d95809c commit a900f90

1 file changed

Lines changed: 8 additions & 7 deletions

File tree

aries_cloudagent/core/conductor.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -482,7 +482,8 @@ async def start(self) -> None:
482482
async def stop(self, timeout=1.0):
483483
"""Stop the agent."""
484484
# notify protcols that we are shutting down
485-
await self.root_profile.notify(SHUTDOWN_EVENT_TOPIC, {})
485+
if self.root_profile:
486+
await self.root_profile.notify(SHUTDOWN_EVENT_TOPIC, {})
486487

487488
shutdown = TaskQueue()
488489
if self.dispatcher:
@@ -494,13 +495,13 @@ async def stop(self, timeout=1.0):
494495
if self.outbound_transport_manager:
495496
shutdown.run(self.outbound_transport_manager.stop())
496497

497-
# close multitenant profiles
498-
multitenant_mgr = self.context.inject_or(BaseMultitenantManager)
499-
if multitenant_mgr:
500-
for profile in multitenant_mgr.open_profiles:
501-
shutdown.run(profile.close())
502-
503498
if self.root_profile:
499+
# close multitenant profiles
500+
multitenant_mgr = self.context.inject_or(BaseMultitenantManager)
501+
if multitenant_mgr:
502+
for profile in multitenant_mgr.open_profiles:
503+
shutdown.run(profile.close())
504+
504505
shutdown.run(self.root_profile.close())
505506

506507
await shutdown.complete(timeout)

0 commit comments

Comments
 (0)