Message10128

Author zyasoft
Recipients the, zyasoft
Date 2015-06-22.21:05:57
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1435007158.52.0.197779576184.issue2371@psf.upfronthosting.co.za>
In-reply-to
Content
This one is a little bit tricky. CPython ensures signal delivery to the main thread, which especially works well for single-threaded programs like the one from Stack Overflow. But Java delivers signals to a separate signal handling thread.

Perhaps this is why the author in the SO question you referenced (http://stackoverflow.com/a/494273/423006) states:

> This module doesn't play well with threads (but then, who does?)

The reality is that signal handling can be made to work well on CPython and Jython in a portable fashion. So in practice you should follow the advice in http://snakesthatbite.blogspot.com/2010/09/cpython-threading-interrupting.html, although IMHO it's a bit overkill - Python memory model semantics ensure that even a simple boolean flag would work just fine, not just `threading.Event`.
History
Date User Action Args
2015-06-22 21:05:58zyasoftsetmessageid: <1435007158.52.0.197779576184.issue2371@psf.upfronthosting.co.za>
2015-06-22 21:05:58zyasoftsetrecipients: + zyasoft, the
2015-06-22 21:05:58zyasoftlinkissue2371 messages
2015-06-22 21:05:57zyasoftcreate