Skip to content

Signal only works in main thread #51

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

Open
weullerk opened this issue Mar 6, 2025 · 2 comments
Open

Signal only works in main thread #51

weullerk opened this issue Mar 6, 2025 · 2 comments

Comments

@weullerk
Copy link

weullerk commented Mar 6, 2025

Hi,

I'm using a lib to rect pack and it uses this library, and I have a error about the signal only running on main thread.

Image

@weullerk
Copy link
Author

weullerk commented Mar 6, 2025

A guy on the python forum give a comment about the situation:

flask responds to requests concurrently using threads
They are using a signal handler to respond gracefully to ctrl+c KeyboardInterrupt
But that doesn't work in an off-main-thread
So they need to do something different when run in an off-main thread, eg no-op the SIGINT handling with a:

try: signal.signal(...) except ValueError: if threading.current_thread() is threading.main_thread(): raise

I particulary resolved the error using the multithread Process class as suggested by graingert on python discord.

@graingert
Copy link

The multiprocessing.Process class not multithreading

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

No branches or pull requests

2 participants