Equivalent of thread.interrupt_main() in Python 3 Equivalent of thread.interrupt_main() in Python 3 python-3.x python-3.x

Equivalent of thread.interrupt_main() in Python 3


Well raising an exception manually is kinda low-level, so if you think you have to do that just use _thread.interrupt_main() since that's the equivalent you asked for (threading module itself doesn't provide this).

It could be that there is a more elegant way to achieve your ultimate goal, though. Maybe setting and checking a flag would be already enough or using a threading.Event like @RFmyD already suggested, or using message passing over a queue.Queue. It depends on your specific setup.