Nir Soffer has uploaded a new change for review.

Change subject: supervdsmServer: Cleaner way to wait for signals
......................................................................

supervdsmServer: Cleaner way to wait for signals

supervdsmServer was using silly way to wait for termination.  Uses now
standard way to do this.

Change-Id: I7f0a1fdd518df1524441fd856fc764f8dbd7cf79
Signed-off-by: Nir Soffer <[email protected]>
---
M vdsm/supervdsmServer
1 file changed, 12 insertions(+), 4 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/19/22719/1

diff --git a/vdsm/supervdsmServer b/vdsm/supervdsmServer
index b3b3bff..408dc4e 100755
--- a/vdsm/supervdsmServer
+++ b/vdsm/supervdsmServer
@@ -80,6 +80,7 @@
 
 RUN_AS_TIMEOUT = config.getint("irs", "process_pool_timeout")
 
+_running = True
 
 class Timeout(RuntimeError):
     pass
@@ -361,6 +362,10 @@
         return self.__udevVersion() > self.UDEV_WITH_RELOAD_VERSION
 
 
+def terminate(signo, frame):
+    global _running
+    _running = False
+
 def main(sockfile, pidfile=None):
     log = logging.getLogger("SuperVdsm.Server")
 
@@ -393,6 +398,9 @@
         log.debug("Setting up keep alive thread")
 
         try:
+            signal.signal(signal.SIGTERM, terminate)
+            signal.signal(signal.SIGINT, terminate)
+
             log.debug("Creating remote object manager")
             manager = _SuperVdsmManager(address=address, authkey='')
             manager.register('instance', callable=_SuperVdsm)
@@ -412,10 +420,10 @@
             _sourceRouteThread.daemon = True
             _sourceRouteThread.start()
 
-            # Python bug of thread.join() will block signal
-            # http://bugs.python.org/issue1167930
-            while servThread.isAlive():
-                servThread.join(5)
+            while _running:
+                signal.pause()
+
+            log.debug("Terminated normally")
         finally:
             if os.path.exists(address):
                 utils.rmFile(address)


-- 
To view, visit http://gerrit.ovirt.org/22719
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I7f0a1fdd518df1524441fd856fc764f8dbd7cf79
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Nir Soffer <[email protected]>
_______________________________________________
vdsm-patches mailing list
[email protected]
https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches

Reply via email to