[etwist] twisted won't install signal handler outside the main thread. stable
authorPierre-Yves David <pierre-yves.david@logilab.fr>
Tue, 01 Jun 2010 17:44:55 +0200
branchstable
changeset 5652 904091dc4c7e
parent 5651 95f7285e85e2
child 5655 ef903fff826d
child 5656 abe97430b3f5
[etwist] twisted won't install signal handler outside the main thread. This patch avoid some warning about this issue.
etwist/server.py
--- a/etwist/server.py	Tue Jun 01 17:29:49 2010 +0200
+++ b/etwist/server.py	Tue Jun 01 17:44:55 2010 +0200
@@ -25,6 +25,7 @@
 import select
 import errno
 import traceback
+import threading
 from os.path import join
 from time import mktime
 from datetime import date, timedelta
@@ -407,8 +408,11 @@
         os.setuid(uid)
     root_resource.start_service()
     logger.info('instance started on %s', root_resource.base_url)
+    # avoid annoying warnign if not in Main Thread
+    signals = threading.currentThread().getName() == 'MainThread'
     if config['profile']:
         import cProfile
-        cProfile.runctx('reactor.run()', globals(), locals(), config['profile'])
+        cProfile.runctx('reactor.run(installSignalHandlers=%s)' % signals,
+                        globals(), locals(), config['profile'])
     else:
-        reactor.run()
+        reactor.run(installSignalHandlers=signals)