Skip to content

Commit 389d205

Browse files
author
Andrei Neagu
committed
avoids earli garbage collection
1 parent b026b90 commit 389d205

File tree

1 file changed

+5
-1
lines changed
  • services/dynamic-sidecar/src/simcore_service_dynamic_sidecar/modules/outputs

1 file changed

+5
-1
lines changed

services/dynamic-sidecar/src/simcore_service_dynamic_sidecar/modules/outputs/_manager.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,9 @@ async def _upload_ports() -> None:
148148
task_name = f"outputs_manager_port_keys-{'_'.join(port_keys)}"
149149
self._task_uploading = create_task(_upload_ports(), name=task_name)
150150

151+
# used to retain task to avoid early garabage collection
152+
cleanup_task: Task | None = None
153+
151154
def _remove_downloads(future: Future) -> None:
152155
# pylint: disable=protected-access
153156
if future._exception is not None:
@@ -171,7 +174,8 @@ def _remove_downloads(future: Future) -> None:
171174
except Exception as e: # pylint: disable=broad-except
172175
self._last_upload_error_tracker[port_key] = e
173176

174-
create_task(self._port_key_tracker.remove_all_uploading())
177+
nonlocal cleanup_task
178+
cleanup_task = create_task(self._port_key_tracker.remove_all_uploading())
175179

176180
self._task_uploading.add_done_callback(_remove_downloads)
177181

0 commit comments

Comments
 (0)