Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions src/apify/_actor.py
Original file line number Diff line number Diff line change
Expand Up @@ -249,11 +249,21 @@ async def finalize() -> None:
if self._event_listeners_timeout:
await self.event_manager.wait_for_all_listeners_to_complete(timeout=self._event_listeners_timeout)

await self.event_manager.__aexit__(None, None, None)
await self._charging_manager_implementation.__aexit__(None, None, None)
try:
await self.event_manager.__aexit__(None, None, None)
except Exception:
self.log.exception('Failed to exit event manager')

try:
await self._charging_manager_implementation.__aexit__(None, None, None)
except Exception:
self.log.exception('Failed to exit charging manager')

# Persist Actor state
await self._save_actor_state()
try:
await self._save_actor_state()
except Exception:
self.log.exception('Failed to save Actor state')

try:
await asyncio.wait_for(finalize(), self._cleanup_timeout.total_seconds())
Expand Down
Loading