[elbe-devel] [PATCH] config/soap: socket timeout env variable

bage at linutronix.de bage at linutronix.de
Sun Feb 2 21:04:50 CET 2020


From: Bastian Germann <bage at linutronix.de>

Introduce an environment variable ELBE_SOAPTIMEOUT_SECS that controls the SOAP
client's socket timeout which defaults to 90 seconds.  Keep the default for the
environment variable as well.

Signed-off-by: Bastian Germann <bage at linutronix.de>
---
 elbepack/config.py     | 4 ++++
 elbepack/soapclient.py | 3 ++-
 elbepack/updated.py    | 3 ++-
 3 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/elbepack/config.py b/elbepack/config.py
index 7ef2910f9..631e33a70 100644
--- a/elbepack/config.py
+++ b/elbepack/config.py
@@ -13,6 +13,7 @@ class Config(dict):
         dict.__init__(self)
         self['soaphost'] = "localhost"
         self['soapport'] = "7587"
+        self['soaptimeout'] = 90
         self['sshport'] = "5022"
         self['elbeuser'] = "root"
         self['elbepass'] = "foo"
@@ -28,6 +29,9 @@ class Config(dict):
         if 'ELBE_SOAPHOST' in os.environ:
             self['soaphost'] = os.environ['ELBE_SOAPHOST']
 
+        if 'ELBE_SOAPTIMEOUT_SECS' in os.environ:
+            self['soaptimeout'] = int(os.environ['ELBE_SOAPTIMEOUT_SECS'])
+
         if 'ELBE_USER' in os.environ:
             self['elbeuser'] = os.environ['ELBE_USER']
 
diff --git a/elbepack/soapclient.py b/elbepack/soapclient.py
index d5b18c2ca..1ecaee0ba 100644
--- a/elbepack/soapclient.py
+++ b/elbepack/soapclient.py
@@ -28,6 +28,7 @@ import deb822   # package for dealing with Debian related data
 from suds.client import Client
 from suds import WebFault
 
+from elbepack.config import cfg
 from elbepack.filesystem import Filesystem
 from elbepack.elbexml import ElbeXML, ValidationMode
 from elbepack.version import elbe_version, elbe_initvm_packagelist
@@ -65,7 +66,7 @@ class ElbeSoapClient(object):
         while self.control is None:
             self.retries += 1
             try:
-                self.control = Client(self.wsdl)
+                self.control = Client(self.wsdl, timeout=cfg['soaptimeout'])
             except socket.error as e:
                 if self.retries > retries:
                     raise e
diff --git a/elbepack/updated.py b/elbepack/updated.py
index e341848b2..f7bf939f8 100644
--- a/elbepack/updated.py
+++ b/elbepack/updated.py
@@ -33,6 +33,7 @@ import apt_pkg
 
 from elbepack.aptprogress import (ElbeInstallProgress,
                                   ElbeAcquireProgress, ElbeOpProgress)
+from elbepack.config import cfg
 from elbepack.egpg import unsign_file
 from elbepack.treeutils import etree
 from elbepack.shellhelper import CommandError, system
@@ -150,7 +151,7 @@ class UpdateService (ServiceBase):
 
     @rpc(String)
     def register_monitor(self, wsdl_url):
-        self.app.status.monitor = Client(wsdl_url)
+        self.app.status.monitor = Client(wsdl_url, timeout=cfg['soaptimeout'])
         self.app.status.log("connection established")
 
 
-- 
2.20.1




More information about the elbe-devel mailing list