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

54 figure out a better alternative for the celery subprocess in subprocess problem #58

Conversation

lfse-slafleur
Copy link
Member

No description provided.

…d upon a cancel and encapsulate SystemExit exceptions which are thrown by Mesido into an EarlySystemExit.
update_progress_function=None,
profile_reader=InfluxDBProfileReader,
)
except SystemExit as e:
Copy link
Member Author

Choose a reason for hiding this comment

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

This is only triggered when mesido throws the SystemExit as it runs in a subprocess

output_esdl = pool.map(run_mesido, [input_esdl])[0]
try:
output_esdl = pool.map(run_mesido, [input_esdl])[0]
except SystemExit as e:
Copy link
Member Author

Choose a reason for hiding this comment

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

This is triggered when Celery throws a SystemExit to cancel the current task. It will terminate the mesido worker subprocess with a SIGKILL to ensure it does not wait till it dies gracefully. Casadi is blocking any way to gracefully shutdown the process as it doesn't release the GIL.

@@ -23,6 +26,16 @@
GROW_TASK_TYPE = GrowTaskType(os.environ.get("GROW_TASK_TYPE"))


class EarlySystemExit(Exception):
Copy link
Member Author

Choose a reason for hiding this comment

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

Moved from omotes-sdk-python to here. As Celery uses the SystemExit mechanism to also stop the running worker gracefully, before it would catch the SystemExit and not let the worker process terminate as expected.

@lfse-slafleur lfse-slafleur merged commit 905d491 into main Jun 17, 2024
11 checks passed
@lfse-slafleur lfse-slafleur deleted the 54-figure-out-a-better-alternative-for-the-celery-subprocess-in-subprocess-problem branch June 17, 2024 14:46
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.

Figure out a better alternative for the Celery subprocess in subprocess problem
2 participants