From 58eba8a9a4884d5f4c57ff8529c71738b8836856 Mon Sep 17 00:00:00 2001 From: "ralf@brainbot.com" Date: Mon, 8 Jun 2009 15:14:40 +0200 Subject: [PATCH] restart system calls on SIGCHLD signals (needed for OS X) this only works in python >= 2.6. --HG-- branch : trunk --- contrib/pytest_twisted/__init__.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/contrib/pytest_twisted/__init__.py b/contrib/pytest_twisted/__init__.py index 215e207b6..81116bc6f 100644 --- a/contrib/pytest_twisted/__init__.py +++ b/contrib/pytest_twisted/__init__.py @@ -44,6 +44,17 @@ def _run_twisted(logging=False): failure.Failure.cleanFailure = lambda *args: None if logging: _start_twisted_logging() + + def fix_signal_handling(): + # see http://twistedmatrix.com/trac/ticket/733 + import signal + if hasattr(signal, "siginterrupt"): + signal.siginterrupt(signal.SIGCHLD, False) + + def start(): + fix_signal_handling() + doit(None) + # recursively called for each test-function/method due done() def doit(val): # val always None # switch context to wait that wrapper() passes back to test-method @@ -64,7 +75,7 @@ def _run_twisted(logging=False): # of doit() defer.maybeDeferred(res).addCallback(done).addErrback(err) # initially preparing the calling of doit() and starting the reactor - reactor.callLater(0.0, doit, None) + reactor.callLater(0.0, start) reactor.run() def pytest_addoption(parser):