On Thu, 25 Jun 2020 18:32:48 -0700
Yonatan Zunger via Python-ideas
<python-ideas@python.org> wrote:
> 
> So that's an example of why you might find yourself in such a situation in
> userland. And overall, Python's signal handling mechanism is pretty good;
> it's *way* nicer than having to deal with it in C, since signal handlers
> run in the main thread as more-or-less ordinary Python code, and you don't
> have to deal with the equivalent of signal-safety and the like. The
> downside of that flexibility, though, is that some tasks like deferring
> signals end up being *really hard* in the Python layer, because even
> appending the signum to an array isn't atomic enough to guarantee that it
> won't be interrupted by another signal.

If you want to serialize execution of signal handlers, it seems like
the best course of action would be to use signal.set_wakeup_fd() and
process incoming signals in an event loop.

Other than that, SimpleQueue may help as well, since it's specifically
meant to be reentrant:
https://docs.python.org/3/library/queue.html#simplequeue-objects

Regards

Antoine.

_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/WOZ4TJHZ3AOSYIWWWKS4QUC6TYJIQP2J/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to