- print(err, file=sys.stderr)
- reactor.callLater(c.http_retry, req_fin)
-
-def req_fin(*args):
- global outstanding
- outstanding -= 1
+ # called when the Deferred fails, or (if it completes),
+ # later, by ResponsConsumer or ErrorResponsConsumer
+ try:
+ log_debug(DBG.HTTP_CTRL, 'req_err ' + str(err), idof=req)
+ if isinstance(err, twisted.python.failure.Failure):
+ err = err.getTraceback()
+ print('[%#x] %s' % (id(req), err), file=sys.stderr)
+ if not isinstance(outstanding[req], int):
+ raise RuntimeError('[%#x] previously %s' % (id(req), outstanding[req]))
+ outstanding[req] = err
+ log_outstanding()
+ reactor.callLater(c.http_retry, partial(req_fin, req))
+ except Exception as e:
+ crash(traceback.format_exc() + '\n----- handling -----\n' + err)
+
+def req_fin(req):
+ del outstanding[req]
+ log_debug(DBG.HTTP_CTRL, 'req_fin OS=%d' % len(outstanding), idof=req)