chiark / gitweb /
it pings!
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 1 Apr 2017 23:48:47 +0000 (00:48 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 1 Apr 2017 23:48:47 +0000 (00:48 +0100)
client
hippotat/__init__.py

diff --git a/client b/client
index e6ea8ed..83dfd66 100755 (executable)
--- a/client
+++ b/client
@@ -93,7 +93,7 @@ class ResponseConsumer(GeneralResponseConsumer):
       return
     try:
       self._ssd.flush()
-      req_fin(req)
+      req_fin(self._req)
     except Exception as e:
       self._handleexception()
 
@@ -154,7 +154,7 @@ def req_err(req, err):
       raise RuntimeError('[%#x] previously %s' % (id(req), outstanding[req]))
     outstanding[req] = err
     log_outstanding()
-    reactor.callLater(c.http_retry, (lambda: req_fin(req)))
+    reactor.callLater(c.http_retry, partial(req_fin, req))
   except Exception as e:
     crash(traceback.format_exc() + '\n----- handling -----\n' + err)
 
@@ -163,6 +163,12 @@ def req_fin(req):
   log_debug(DBG.HTTP_CTRL, 'req_fin OS=%d' % len(outstanding), idof=req)
   check_outbound()
 
+class Errb:
+  def __init__(self, req):
+    self._req = req
+  def call(self, err):
+    req_err(self._req, err)
+
 def check_outbound():
   global outstanding
 
@@ -216,8 +222,8 @@ def check_outbound():
     outstanding[req] = len(d)
     log_debug(DBG.HTTP_CTRL, 'request OS=%d' % len(outstanding), idof=req, d=d)
     req.addTimeout(c.http_timeout, reactor)
-    req.addCallback((lambda resp: req_ok(req, resp)))
-    req.addErrback((lambda err: req_err(req, err)))
+    req.addCallback(partial(req_ok, req))
+    req.addErrback(partial(req_err, req))
 
   log_outstanding()
 
index 3e8649a..5d5129a 100644 (file)
@@ -20,6 +20,8 @@ from optparse import OptionParser
 from configparser import ConfigParser
 from configparser import NoOptionError
 
+from functools import partial
+
 import collections
 import time
 import codecs