--- a/Beremiz_service.py Tue Aug 16 19:52:49 2022 +0200
+++ b/Beremiz_service.py Tue Aug 16 23:42:42 2022 +0200
@@ -37,6 +37,7 @@
from builtins import str as text
from past.builtins import execfile
from six.moves import builtins
+from functools import partial from runtime.PyroServer import PyroServer
@@ -547,30 +548,6 @@
LogMessageAndException(_("WAMP client startup failed. "))
-if havetwisted or havewx:
- # reactor._installSignalHandlersAgain()
- waker_func = reactor._runInMainThread
- def ui_blocking_call():
- # FIXME: had to disable SignaHandlers install because
- # signal not working in non-main thread
- reactor.run(installSignalHandlers=False)
- waker_func = wx.CallAfter
- ui_blocking_call = app.MainLoop
- def ui_launched_report():
- # IDE expects to see that string to stop waiting for runtime
- # to be ready and connnect to it.
- print("UI thread started successfully.")
- # This orders ui loop to signal when ready on Stdout
- reactor.callLater(0, ui_launched_report)
- wx.CallAfter(ui_launched_report)
@@ -601,19 +578,33 @@
runtime.GetPLCObjectSingleton().AutoLoad(autostart)
- if havetwisted or havewx:
- # worker that copes with wx and (wx)reactor
- runtime.MainWorker.interleave(waker_func, FirstWorkerJob)
- runtime.MainWorker.stop()
+if havetwisted or havewx: + waker_func = wx.CallAfter if havewx else partial(reactor.callLater,0) + # This orders ui loop to signal when ready on Stdout + waker_func(print,"UI thread started successfully.") + # worker that copes with wx and (wx)reactor + runtime.MainWorker.interleave(waker_func, FirstWorkerJob)
+ reactor.run(installSignalHandlers=False) + except KeyboardInterrupt: + runtime.MainWorker.stop() runtime.MainWorker.runloop(FirstWorkerJob)
+ except KeyboardInterrupt: -except KeyboardInterrupt:
--- a/runtime/Worker.py Tue Aug 16 19:52:49 2022 +0200
+++ b/runtime/Worker.py Tue Aug 16 23:42:42 2022 +0200
@@ -123,9 +123,10 @@
- self.own_thread = Thread(target = wakerfeedingloop).start()
+ self.own_thread = Thread(target = wakerfeedingloop) + self.own_thread.start()