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

Fix thread "leak" #502

Merged
merged 1 commit into from
Feb 12, 2025
Merged

Fix thread "leak" #502

merged 1 commit into from
Feb 12, 2025

Conversation

hategan
Copy link
Collaborator

@hategan hategan commented Feb 10, 2025

This fixes #501 by replacing the executor property of _QueuePollThread by weakref and shutting down the thread when
the executor is collected. The weak ref is necessary to avoid a reference loop which would prevent a __del__ based solution from working.

…ular

references and shut down the QueuePollThread when the executor is
garbage collected.
@hategan hategan requested a review from andre-merzky February 10, 2025 21:30
@hategan hategan merged commit 7088769 into main Feb 12, 2025
14 checks passed
@hategan hategan deleted the clean_queue_poll_threads branch February 12, 2025 19:53
with self._jobs_lock:
if len(self._jobs) == 0:
return
jobs_copy = dict(self._jobs)
logger.info('Polling for %s jobs', len(jobs_copy))
try:
out = self.executor._run_command(self.executor.get_status_command(jobs_copy.keys()))
if exec:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if exec is not needed, that is checked above.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, thank you. Will issue a small PR for that.

Copy link
Collaborator

@andre-merzky andre-merzky left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for late response - LGTM!

@hategan
Copy link
Collaborator Author

hategan commented Feb 13, 2025

Sorry for late response - LGTM!

No worries. I thought you were away. Glad you took a look.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

QueuePollThread instance leak
2 participants