Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

👌 IMPROVE: Garbage collect on process termination #4767

Closed
Closed
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
8 changes: 8 additions & 0 deletions aiida/manage/external/rmq.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@
###########################################################################
# pylint: disable=cyclic-import
"""Components to communicate tasks to RabbitMQ."""
import asyncio
from collections.abc import Mapping
import gc
import logging

from kiwipy import communications, Future
Expand Down Expand Up @@ -220,4 +222,10 @@ async def _continue(self, communicator, pid, nowait, tag=None):
LOGGER.exception('failed to serialize the result for process<%d>', pid)
raise

# before returning we ensure the garbage collection runs, to clear any memory used by the task
await asyncio.sleep(1) # allow other async tasks to complete first
del node
del result
gc.collect()

return serialized