chiark / gitweb /
fixes
[hippotat.git] / client
diff --git a/client b/client
index a56dde2fbc0f92ec5321c0ba80465aed373184eb..e9bce7c2370b80d22c85162b75e680b67a33b98e 100755 (executable)
--- a/client
+++ b/client
@@ -25,6 +25,7 @@ class ResponseConsumer(GeneralResponseConsumer):
     ssddesc = '[%s] %s' % (id(req), self._desc)
     self._ssd = SlipStreamDecoder(ssddesc, cl.queue_inbound)
     self._log(DBG.HTTP_CTRL, '__init__')
+    self._success_reported = False
 
   def dataReceived(self, data):
     self._log(DBG.HTTP, 'dataReceived', d=data)
@@ -44,6 +45,9 @@ class ResponseConsumer(GeneralResponseConsumer):
       self.cl.req_fin(self._req)
     except Exception as e:
       self._handleexception()
+    if not self._success_reported:
+      log.info(cl.desc + 'running OK', dflag=False)
+      self._success_reported = True
 
   def _handleexception(self):
     self._latefailure(traceback.format_exc())
@@ -83,12 +87,13 @@ class Client():
     cl.c = c
     cl.outstanding = { }
     cl.desc = '[%s %s] ' % (ss,cs)
+    log.info(cl.desc + 'setting up', dflag=False)
 
   def log(cl, dflag, msg, **kwargs):
     log_debug(dflag, cl.desc + msg, **kwargs)
 
   def log_outstanding(cl):
-    cl.log(DBG.CTRL_DUMP, 'OS %s' % outstanding)
+    cl.log(DBG.CTRL_DUMP, 'OS %s' % cl.outstanding)
 
   def start(cl):
     cl.queue = PacketQueue('up', cl.c.max_queue_time)
@@ -120,8 +125,9 @@ class Client():
       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]))
+      if not isinstance(cl.outstanding[req], int):
+        raise RuntimeError('[%#x] previously %s' %
+                           (id(req), cl.outstanding[req]))
       cl.outstanding[req] = err
       cl.log_outstanding()
       reactor.callLater(cl.c.http_retry, partial(cl.req_fin, req))
@@ -130,7 +136,7 @@ class Client():
 
   def req_fin(cl, req):
     del cl.outstanding[req]
-    cl.log(DBG.HTTP_CTRL, 'req_fin OS=%d' % len(outstanding), idof=req)
+    cl.log(DBG.HTTP_CTRL, 'req_fin OS=%d' % len(cl.outstanding), idof=req)
     cl.check_outbound()
 
   def check_outbound(cl):
@@ -138,13 +144,13 @@ class Client():
       if len(cl.outstanding) >= cl.c.max_outstanding:
         break
 
-      if (not queue.nonempty() and
-          len(cl.outstanding) >= cl.c.target_outstanding):
+      if (not cl.queue.nonempty() and
+          len(cl.outstanding) >= cl.c.target_requests_outstanding):
         break
 
       d = b''
       def moredata(s): nonlocal d; d += s
-      queue.process((lambda: len(d)),
+      cl.queue.process((lambda: len(d)),
                     moredata,
                     cl.c.max_batch_up)
 
@@ -157,7 +163,8 @@ class Client():
               b'Content-Disposition: form-data; name="m"'   + crlf + crlf +
               str(cl.c.client)            .encode('ascii')  + crlf +
               cl.c.password                                 + crlf +
-              str(cl.c.target_outstanding).encode('ascii')  + crlf +
+              str(cl.c.target_requests_outstanding)
+                                          .encode('ascii')  + crlf +
               str(cl.c.http_timeout)      .encode('ascii')  + crlf +
             ((
               b'--b'                                        + crlf +
@@ -181,7 +188,7 @@ class Client():
       bytesreader = io.BytesIO(mime)
       producer = twisted.web.client.FileBodyProducer(bytesreader)
 
-      req = agent.request(b'POST',
+      req = cl.agent.request(b'POST',
                           cl.c.url,
                           twisted.web.client.Headers(hh),
                           producer)