From ee3a70ebceb8f4eb86d7c18960249e1e12e233a8 Mon Sep 17 00:00:00 2001 From: Max Date: Wed, 5 Dec 2018 18:18:38 +0100 Subject: [PATCH] Trap handlers: adjust http error log Log repr() of error because it's more conscience which makes it easier to read the logs: in case of "e" there's additional "Failure instance: Traceback (failure with no frames)" prefix which is pretty useless because we won't have proper tracebacks for deferred anyway. Change-Id: I39870b83cacee9a589636974d04e356ef0d32345 --- scripts/ctrl2cgi.py | 2 +- scripts/soap.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/ctrl2cgi.py b/scripts/ctrl2cgi.py index 81674d8..28a7c3b 100755 --- a/scripts/ctrl2cgi.py +++ b/scripts/ctrl2cgi.py @@ -64,7 +64,7 @@ def gen_hash(params, skey): 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 (timeout %d)" % (e, par['bsc_id'], dst, tout))) # handle HTTP errors + d.addErrback(lambda e: f_log.critical("HTTP POST error %s while trying to register BSC %s on %s (timeout %d)" % (repr(e), par['bsc_id'], dst, tout))) # handle HTTP errors return d class Trap(CTRL): diff --git a/scripts/soap.py b/scripts/soap.py index 5817988..0cb2184 100755 --- a/scripts/soap.py +++ b/scripts/soap.py @@ -90,7 +90,7 @@ class Trap(CTRL): ctx = self.factory.client.registerSiteLocation(bsc, float(params['lon']), float(params['lat']), params['position_validity'], params['time_stamp'], params['oper_status'], params['admin_status'], params['policy_status']) d = post(self.factory.location, ctx.envelope) d.addCallback(collect, partial(handle_reply, ctx.process_reply, params['bsc_id'], self.transport.write, self.factory.log)) # treq's collect helper is handy to get all reply content at once using closure on ctx - d.addErrback(lambda e, bsc: self.factory.log.critical("HTTP POST error %s while trying to register BSC %s on %s" % (e, bsc, self.factory.location)), bsc) # handle HTTP errors + d.addErrback(lambda e, bsc: self.factory.log.critical("HTTP POST error %s while trying to register BSC %s on %s" % (repr(e), bsc, self.factory.location)), bsc) # handle HTTP errors # Ensure that we run only limited number of requests in parallel: yield self.factory.semaphore.acquire() yield d # we end up here only if semaphore is available which means it's ok to fire the request without exceeding the limit