Skip to content

_signals.py: allow registering signal handlers from non-main threads

Benjamin Schubert requested to merge bschubert/signals into master

Description

_signals.py: allow calling signal handler from non-main threads

This modifies the signal terminator so that it can be called from any thread.

This checks that either:

  • The signal handler is already in place
  • Or the caller is in the main thread, allowing to set the signal handler.

This also removes the exact callback that was added instead of removing the last one, and fixes the suspend_handler to do the same.

This is required, as we don't know which interleaving of calls will be done, and we can't guarantee that the last one is the right one to remove.

Edited by Benjamin Schubert

Merge request reports