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

signal errors when importing dask_jobqeueue from a thread #667

Closed
zulissimeta opened this issue Aug 28, 2024 · 3 comments · Fixed by #668
Closed

signal errors when importing dask_jobqeueue from a thread #667

zulissimeta opened this issue Aug 28, 2024 · 3 comments · Fixed by #668
Labels
bug Something isn't working

Comments

@zulissimeta
Copy link

If you load dask_jobqueue from a thread (for example, if using with prefect), you will get errors due to the signal.

Code:

signal.signal(signal.SIGINT, lambda *_: sys.exit())

Partial trace:

    handler = _signal.signal(_enum_to_int(signalnum), _enum_to_int(handler))
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ValueError: signal only works in main thread of the main interpreter

I haven't dug into the logic of how this is used and/or why it's needed. Maybe we should only do this if we are in the main thread?

@jacobtomlinson
Copy link
Member

Thanks for raising this! That was added because we were seeing hangs during shutdown without it (see dask/distributed#8644).

You might be right that we only need to do this if we are running in the main thread. I've opened #668 to do this. Would you mind installing the version from that PR and trying it out with Prefect to see if it a) solves your problem and b) doesn't cause the hangs we were seeing previously.

# Install the PR version
pip install git+https://github.com/dask/dask-jobqueue.git@refs/pull/668/merge

@jacobtomlinson jacobtomlinson added the bug Something isn't working label Aug 29, 2024
@zulissimeta
Copy link
Author

zulissimeta commented Sep 5, 2024

Thanks for the quick patch; confirming this fixed the problem!

I didn't notice any hangs in our tests (everything shut down as normal).

@jacobtomlinson
Copy link
Member

Great. I'll merge that PR then!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants