Message307809
If nothing connects to it, `multiprocessing.connection.Listener.accept()` will block forever with no good way to interrupt it.
Supposing that a thread implements a loop like this:
def run(self):
l = Listener(socket_path, 'AF_UNIX')
while self.running:
c = l.accept()
while self.running:
data = c.recv()
self.process(data)
There is no obvious way to implement a `stop` method on this thread. Setting `self.running = False` may never result in the thread terminating, as it may be that no client connects to it. The following is a possible way of implementing it:
def stop(self):
self.running = False
try:
c = Client(socket_path, 'AF_UNIX')
except:
pass
however it seems fraught with race conditions. Letting `accept()` accept a timeout would be a much cleaner solution to this and many similar problems. |
|
Date |
User |
Action |
Args |
2017-12-07 15:09:59 | Tom Cook | set | recipients:
+ Tom Cook |
2017-12-07 15:09:59 | Tom Cook | set | messageid: <1512659399.52.0.213398074469.issue32244@psf.upfronthosting.co.za> |
2017-12-07 15:09:59 | Tom Cook | link | issue32244 messages |
2017-12-07 15:09:59 | Tom Cook | create | |
|