]> www.average.org Git - loctrkd.git/blobdiff - gps303/wsgateway.py
do not try to use zlib's _Decompress
[loctrkd.git] / gps303 / wsgateway.py
index c0a47768254bff754a2425ea1cd40ae597002a06..381a8558a4218f9d56489425ece81d4c4406e6d8 100644 (file)
@@ -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__"):