Join ZMQ process on error
authorThierry Florac <thierry.florac@onf.fr>
Tue, 30 Jun 2015 15:20:45 +0200
changeset 13 1ef4d38681e8
parent 12 254b16bfecaa
child 14 ccf4a5a8053c
Join ZMQ process on error
src/pyams_scheduler/include.py
--- a/src/pyams_scheduler/include.py	Wed Jun 17 09:59:00 2015 +0200
+++ b/src/pyams_scheduler/include.py	Tue Jun 30 15:20:45 2015 +0200
@@ -28,6 +28,7 @@
 from pyams_scheduler.process import SchedulerProcess, SchedulerMessageHandler
 from pyams_utils.zodb import get_connection_from_settings
 from pyams_zmq.process import process_exit_func
+from zmq.error import ZMQError
 
 
 def include_package(config):
@@ -75,6 +76,10 @@
                                                       'registry': config.registry})
                 logger.debug("Starting tasks scheduler {0!r}".format(process))
                 # start process
-                process.start()
-                if process.is_alive():
-                    atexit.register(process_exit_func, process=process)
+                try:
+                    process.start()
+                except ZMQError:
+                    process.join()
+                else:
+                    if process.is_alive():
+                        atexit.register(process_exit_func, process=process)