WAMP : complains about failure to start WAMP only if it was successfully imported. nevow_service_rework
authorEdouard Tisserant
Thu, 12 Jul 2018 09:35:09 +0200
branchnevow_service_rework
changeset 2222 8ac0f1af5589
parent 2221 e03f7649bfb3
child 2223 909216419e45
WAMP : complains about failure to start WAMP only if it was successfully imported.
Beremiz_service.py
--- a/Beremiz_service.py	Wed Jul 11 14:32:19 2018 +0200
+++ b/Beremiz_service.py	Thu Jul 12 09:35:09 2018 +0200
@@ -582,6 +582,7 @@
 
 
 installThreadExcepthook()
+havewamp = False
 
 if havetwisted:
     if webport is not None:
@@ -595,6 +596,7 @@
     try:
         import runtime.WampClient as WC  # pylint: disable=ungrouped-imports
         WC.WorkingDir = WorkingDir
+        havewamp = True
     except Exception:
         LogMessageAndException(_("WAMP import failed :"))
 
@@ -613,12 +615,13 @@
         except Exception:
             LogMessageAndException(_("Nevow Web service failed. "))
 
-    try:
-        WC.SetServer(pyroserver)
-        WC.RegisterWampClient(wampconf, wampsecret)
-        WC.RegisterWebSettings(NS)
-    except Exception:
-        LogMessageAndException(_("WAMP client startup failed. "))
+    if havewamp:
+        try:
+            WC.SetServer(pyroserver)
+            WC.RegisterWampClient(wampconf, wampsecret)
+            WC.RegisterWebSettings(NS)
+        except Exception:
+            LogMessageAndException(_("WAMP client startup failed. "))
 
 pyro_thread_started = Lock()
 pyro_thread_started.acquire()