Runtime: avoids using "pipe to self" bailout unblocking trick on windows, since select() only takes sockets. wxPython4
authorEdouard Tisserant <edouard.tisserant@gmail.com>
Tue, 07 Sep 2021 09:08:40 +0200
branchwxPython4
changeset 3308 358ccd42e052
parent 3307 eeec6e0ea269
child 3309 446b2c3da6e6
Runtime: avoids using "pipe to self" bailout unblocking trick on windows, since select() only takes sockets.
runtime/PyroServer.py
--- a/runtime/PyroServer.py	Sun Sep 05 15:24:14 2021 +0200
+++ b/runtime/PyroServer.py	Tue Sep 07 09:08:40 2021 +0200
@@ -62,8 +62,15 @@
             self.daemon.connect(pyro_obj, "PLCObject")
 
             when_ready()
-            self.piper, self.pipew = os.pipe()
-            self.daemon.requestLoop(others=[self.piper], callback=lambda x: None)
+
+            # "pipe to self" trick to to accelerate runtime shutdown 
+            # instead of waiting for arbitrary pyro timeout.
+            others = []
+            if not sys.platform.startswith('win'):
+                self.piper, self.pipew = os.pipe()
+                others.append = self.piper
+
+            self.daemon.requestLoop(others=others, callback=lambda x: None)
             self.piper, self.pipew = None, None
             if hasattr(self, 'sock'):
                 self.daemon.sock.close()
@@ -76,8 +83,9 @@
         self.continueloop = False
         self.daemon.shutdown(True)
         self.daemon.closedown()
-        if self.pipew is not None:
-            os.write(self.pipew, "goodbye")
+        if not sys.platform.startswith('win'):
+            if self.pipew is not None:
+                os.write(self.pipew, "goodbye")
 
     def Publish(self):
         self.servicepublisher = ServicePublisher("PYRO")