X-Git-Url: http://average.org/gitweb/?a=blobdiff_plain;f=gps303%2Fwsgateway.py;h=381a8558a4218f9d56489425ece81d4c4406e6d8;hb=18eda7307e92eeee6a9e2fdd2e810f98d25df654;hp=c0a47768254bff754a2425ea1cd40ae597002a06;hpb=92436e6943eab06ac87ba24c98f44e3cb270a86d;p=loctrkd.git diff --git a/gps303/wsgateway.py b/gps303/wsgateway.py index c0a4776..381a855 100644 --- a/gps303/wsgateway.py +++ b/gps303/wsgateway.py @@ -152,7 +152,11 @@ class Client: e, ) self.ws_data = try_http(data, self.sock.fileno(), e) - self.write() # TODO this is a hack + # this `write` is a hack - writing _ought_ to be done at the + # stage when all other writes are performed. But I could not + # arrange it so in a logical way. Let it stay this way. The + # whole http server affair is a hack anyway. + self.write() log.debug("Sending HTTP response to %d", self.sock.fileno()) msgs = None else: @@ -255,7 +259,7 @@ def runserver(conf: ConfigParser) -> None: global htmlfile initdb(conf.get("storage", "dbfn")) - htmlfile = conf.get("wsgateway", "htmlfile") + htmlfile = conf.get("wsgateway", "htmlfile", fallback=None) # Is this https://github.com/zeromq/pyzmq/issues/1627 still not fixed?! zctx = zmq.Context() # type: ignore zsub = zctx.socket(zmq.SUB) # type: ignore @@ -398,7 +402,9 @@ def runserver(conf: ConfigParser) -> None: towait &= trywrite towait |= morewait except KeyboardInterrupt: - pass + zsub.close() + zctx.destroy() # type: ignore + tcpl.close() if __name__.endswith("__main__"):