Change in python/osmo-python-tests[master]: ctrl2cgi: make http request timeout configurable

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

Harald Welte gerrit-no-reply at lists.osmocom.org
Thu Dec 6 09:54:48 UTC 2018


Harald Welte has submitted this change and it was merged. ( https://gerrit.osmocom.org/12148 )

Change subject: ctrl2cgi: make http request timeout configurable
......................................................................

ctrl2cgi: make http request timeout configurable

Change-Id: I7839121da831aeab0be7e599049bf79471f845fd
Related: SYS#4399
---
M scripts/ctrl2cgi.py
1 file changed, 6 insertions(+), 5 deletions(-)

Approvals:
  Jenkins Builder: Verified
  daniel: Looks good to me, but someone else must approve
  Harald Welte: Looks good to me, approved



diff --git a/scripts/ctrl2cgi.py b/scripts/ctrl2cgi.py
index e11e6e6..81674d8 100755
--- a/scripts/ctrl2cgi.py
+++ b/scripts/ctrl2cgi.py
@@ -22,7 +22,7 @@
  */
 """
 
-__version__ = "0.0.7" # bump this on every non-trivial change
+__version__ = "0.0.8" # bump this on every non-trivial change
 
 import argparse, os, logging, logging.handlers, datetime
 import hashlib
@@ -61,10 +61,10 @@
     #print('HASH: \nparams="%r"\ninput="%s" \nres="%s"' %(params, input, res))
     return res
 
-def make_async_req(ts, dst, par, f_write, f_log):
-    d = post(dst, par)
+def make_async_req(ts, dst, par, f_write, f_log, tout):
+    d = post(dst, par, timeout=tout)
     d.addCallback(collect, partial(handle_reply, ts, par['bsc_id'], f_write, f_log)) # treq's collect helper is handy to get all reply content at once
-    d.addErrback(lambda e: f_log.critical("HTTP POST error %s while trying to register BSC %s on %s" % (e, par['bsc_id'], dst))) # handle HTTP errors
+    d.addErrback(lambda e: f_log.critical("HTTP POST error %s while trying to register BSC %s on %s (timeout %d)" % (e, par['bsc_id'], dst, tout))) # handle HTTP errors
     return d
 
 class Trap(CTRL):
@@ -110,7 +110,7 @@
         t = datetime.datetime.now()
         self.factory.log.debug('Preparing request for BSC %s @ %s...' % (params['bsc_id'], t))
         # Ensure that we run only limited number of requests in parallel:
-        self.factory.semaphore.run(make_async_req, t, self.factory.location, params, self.transport.write, self.factory.log)
+        self.factory.semaphore.run(make_async_req, t, self.factory.location, params, self.transport.write, self.factory.log, self.factory.timeout)
 
     def handle_notificationrejectionv1(self, net, bsc, bts, trx, data):
         """
@@ -148,6 +148,7 @@
 
     T.addr_ctrl = config['main'].get('addr_ctrl', 'localhost')
     T.port_ctrl = config['main'].getint('port_ctrl', 4250)
+    T.timeout = config['main'].getint('timeout', 30)
     T.semaphore = defer.DeferredSemaphore(config['main'].getint('num_max_conn', 5))
     T.location = config['main'].get('location')
     T.secret_key = config['main'].get('secret_key')

-- 
To view, visit https://gerrit.osmocom.org/12148
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: python/osmo-python-tests
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I7839121da831aeab0be7e599049bf79471f845fd
Gerrit-Change-Number: 12148
Gerrit-PatchSet: 1
Gerrit-Owner: Max <msuraev at sysmocom.de>
Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Jenkins Builder (1000002)
Gerrit-Reviewer: Pau Espin Pedrol <pespin at sysmocom.de>
Gerrit-Reviewer: daniel <dwillmann at sysmocom.de>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20181206/e359555e/attachment.htm>


More information about the gerrit-log mailing list