unexpected behavior when iterating over a pipe
import vanilla
import signal
h = vanilla.Hub()
p = h.process.execv(('/bin/sleep', '30000'))
done = h.router()
h.signal.subscribe(signal.SIGINT, signal.SIGTERM).pipe(done)
p.done.pipe(done)
svc_name = 'test_service'
cclient = h.consul()
for x in done.recver:
if type(x) == int:
print 'killing child'
p.terminate()
else:
cclient.agent.service.deregister(svc_name).recv()
done.close()
throws:
[david@foulplay]$ python /tmp/t.py
killing child
Traceback (most recent call last):
File "/tmp/t.py", line 22, in <module>
done.close()
File "/usr/lib/python2.7/dist-packages/vanilla/message.py", line 104, in close
self.recver.close()
File "/usr/lib/python2.7/dist-packages/vanilla/message.py", line 222, in close
self.hub.throw_to(self.other.current, exception)
File "/usr/lib/python2.7/dist-packages/vanilla/core.py", line 335, in throw_to
return target.throw(*a)
AttributeError: 'collections.deque' object has no attribute 'throw'
Ugh.. looking through things, this is happening as Router's sender keeps a deque of waiting senders and close assumes their will just be one sender, which is represented as a green thread. Basically, there's still work to be done so everything can be seamlessly plug together :( ..
Want to chat through tomorrow?
sounds good.
since i only need to break out of the loop, i have plenty of options as workarounds.
On Mon, Nov 16, 2015, 6:07 PM Andy Gayton [email protected] wrote:
Ugh.. looking through things, this is happening as Router's sender keeps a deque of waiting senders and close assumes their will just be one sender, which is represented as a green thread. Basically, there's still work to be done so everything can be seamlessly plug together :( ..
Want to chat through tomorrow?
— Reply to this email directly or view it on GitHub https://github.com/cablehead/vanilla/issues/21#issuecomment-157238516.