import zmq
from . import common
-from .gps303proto import parse_message, WIFI_POSITIONING
+from .gps303proto import parse_message, proto_name, WIFI_POSITIONING
from .zmsg import Bcast, Resp, topic
log = getLogger("gps303/lookaside")
zctx = zmq.Context() # type: ignore
zsub = zctx.socket(zmq.SUB) # type: ignore
zsub.connect(conf.get("collector", "publishurl"))
- zsub.setsockopt(zmq.SUBSCRIBE, topic(WIFI_POSITIONING.PROTO))
+ zsub.setsockopt(zmq.SUBSCRIBE, topic(proto_name(WIFI_POSITIONING)))
zpush = zctx.socket(zmq.PUSH) # type: ignore
zpush.connect(conf.get("collector", "listenurl"))
log.warning("Lookup for %s resulted in %s", msg, e)
except KeyboardInterrupt:
- pass
+ zsub.close()
+ zpush.close()
+ zctx.destroy() # type: ignore
+ qry.shut()
if __name__.endswith("__main__"):