[issue12410] Create a new helper function that enable to test that an operation don't hang more than a given timeout.

Charles-François Natali report at bugs.python.org
Sat Jun 25 17:59:03 CEST 2011


Charles-François Natali <neologix at free.fr> added the comment:

It's a little bit more complicated than that:
- signals and threads don't mix well together
- this will make syscalls fail with EINTR
- the old SIGALRM handler is lost
- etc

In short, don't use signals.
I'm not sure there's a reliable way to write such a general-purpose wrapper (usually one can use select() with a timeout or spawn a subprocess and use communicate's timeout to achieve this kind of things).
In your use case (issue #12157), I think that letting the test block is fine, since:
- there's no easy way to add a timeout (but you could spawn a new interpreter and use communicate with a timeout if you really wanted to)
- it will be caught by the faulthandler module
- a test killed by faulthandler's timeout is more interesting to fix that a "common" failed test ;-)

----------
nosy: +neologix

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue12410>
_______________________________________


More information about the Python-bugs-list mailing list