--- a/Beremiz_service.py Wed Sep 14 15:24:33 2022 +0200
+++ b/Beremiz_service.py Wed Oct 05 16:10:17 2022 +0200
@@ -423,7 +423,12 @@
from twisted.internet import wxreactor
- from twisted.internet import reactor
+ from twisted.internet import reactor + reactor.registerWxApp(app) + # from twisted.internet import pollreactor + # pollreactor.install() + from twisted.internet import reactor @@ -432,11 +437,6 @@
- reactor.registerWxApp(app)
wx_eval_lock = Semaphore(0)
@@ -578,26 +578,50 @@
runtime.GetPLCObjectSingleton().AutoLoad(autostart)
-if havetwisted or havewx:
+if havetwisted and havewx: - waker_func = wx.CallAfter if havewx else partial(reactor.callLater,0)
+ waker_func = wx.CallAfter # 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
+ # interleaved worker copes with wxreactor by delegating all asynchronous + # calls to wx's mainloop runtime.MainWorker.interleave(waker_func, FirstWorkerJob)
- reactor.run(installSignalHandlers=False)
+ reactor.run(installSignalHandlers=False) except KeyboardInterrupt:
runtime.MainWorker.stop()
+ except KeyboardInterrupt: + ui_thread_started = Lock() + ui_thread_started.acquire() + reactor.callLater(0, ui_thread_started.release) + target=partial(reactor.run, installSignalHandlers=False), + ui_thread_started.acquire() + print("UI thread started successfully.") + runtime.MainWorker.runloop(FirstWorkerJob) + except KeyboardInterrupt: @@ -618,6 +642,8 @@