Issue2371
Created on 2015-06-22.08:55:17 by the, last changed 2015-07-06.21:00:30 by zyasoft.
msg10127 (view) |
Author: the (the) |
Date: 2015-06-22.08:56:58 |
|
When trying to do the same as described in the following stack overflow answer: http://stackoverflow.com/questions/492519/timeout-on-a-python-function-call
jython throws an exception, but does not stop the execution of "loop_forever"
This exception is thrown
Exception in thread "SIGALRM handler" Traceback (most recent call last):
File "/home/st/svn/stefan/trunk/GEVA-v2.0/GEVA/lib/Jython/jython-standalone-2.7.0.jar/Lib/signal.py", line 117, in handle
File "<stdin>", line 3, in signal_handler
|
msg10128 (view) |
Author: Jim Baker (zyasoft) |
Date: 2015-06-22.21:05:57 |
|
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`.
|
|
Date |
User |
Action |
Args |
2015-07-06 21:00:30 | zyasoft | set | status: pending -> closed |
2015-06-22 21:05:58 | zyasoft | set | status: open -> pending resolution: wont fix messages:
+ msg10128 nosy:
+ zyasoft |
2015-06-22 08:56:58 | the | set | messages:
+ msg10127 |
2015-06-22 08:55:17 | the | create | |
|