Skip to content

Commit 526af53

Browse files
vdusekclaude
andcommitted
fix: Handle exceptions in pre-reboot event listeners via return_exceptions
Use `return_exceptions=True` in `asyncio.gather` during Actor reboot so that a failing listener does not prevent other listeners from persisting state. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 5e4f773 commit 526af53

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/apify/_actor.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1194,11 +1194,16 @@ async def reboot(
11941194
(self.event_manager._listeners_to_wrappers[Event.MIGRATING] or {}).values() # noqa: SLF001
11951195
)
11961196

1197-
await asyncio.gather(
1197+
results = await asyncio.gather(
11981198
*[listener(EventPersistStateData(is_migrating=True)) for listener in persist_state_listeners],
11991199
*[listener(EventMigratingData()) for listener in migrating_listeners],
1200+
return_exceptions=True,
12001201
)
12011202

1203+
for result in results:
1204+
if isinstance(result, Exception):
1205+
self.log.exception('A pre-reboot event listener failed', exc_info=result)
1206+
12021207
if not self.configuration.actor_run_id:
12031208
raise RuntimeError('actor_run_id cannot be None when running on the Apify platform.')
12041209

0 commit comments

Comments
 (0)