forked from M-Labs/artiq
dashboard/moninj: fix windows problems
This commit is contained in:
parent
e4833a33fc
commit
a6c17d3e40
|
@ -263,6 +263,7 @@ class MonInj(TaskObject):
|
|||
self.subscriber = Subscriber("devices", self.init_devices)
|
||||
self.dm = None
|
||||
self.socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
|
||||
self.socket.bind(("", 39284))
|
||||
# Never ceasing to disappoint, asyncio has an issue about UDP
|
||||
# not being supported on Windows (ProactorEventLoop) open since 2014.
|
||||
self.loop = asyncio.get_event_loop()
|
||||
|
@ -293,8 +294,13 @@ class MonInj(TaskObject):
|
|||
|
||||
def receiver_thread(self):
|
||||
while True:
|
||||
try:
|
||||
data, addr = self.socket.recvfrom(2048)
|
||||
except OSError:
|
||||
# Windows does this when the socket is terminated
|
||||
break
|
||||
if addr is None:
|
||||
# Linux does this when the socket is terminated
|
||||
break
|
||||
self.loop.call_soon_threadsafe(self.datagram_received, data)
|
||||
|
||||
|
|
Loading…
Reference in New Issue