Skip to content

Instantly share code, notes, and snippets.

@hpk42
Created September 16, 2013 09:17
Show Gist options
  • Save hpk42/6578366 to your computer and use it in GitHub Desktop.
Save hpk42/6578366 to your computer and use it in GitHub Desktop.
in case of a whole remote gateway gone:
>>> import execnet
>>> gw=execnet.makegateway()
>>> gw._rinfo()
<RInfo "platform=linux2, executable=/home/hpk/venv/0/bin/python, pid=22601, cwd=/home/hpk/p/devpi, version_info=(2, 7, 3, 'final', 0)">
>>> os.kill(22601, 9)
>>> gw.remote_exec("hello")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/hpk/p/execnet/execnet/gateway.py", line 117, in remote_exec
channel = self.newchannel()
File "/home/hpk/p/execnet/execnet/gateway_base.py", line 716, in newchannel
return self._channelfactory.new()
File "/home/hpk/p/execnet/execnet/gateway_base.py", line 484, in new
raise IOError("connexion already closed: %s" % (self.gateway,))
IOError: connexion already closed: <Gateway id='gw0' not-receiving, 0 active channels>
or in case of a broken channel:
>>> gw=execnet.makegateway()
>>> gw._rinfo()
<RInfo "platform=linux2, executable=/home/hpk/venv/0/bin/python, pid=22959, cwd=/home/hpk/p/devpi, version_info=(2, 7, 3, 'final', 0)">
>>> gw.remote_exec("""
while 1:
channel.send(channel.receive())
""")
<Channel id=3 open>
>>> ch=_
>>> ch.send(1)
>>> ch.receive()
1
>>> os.kill(22959, 9)
>>> ch.send(1)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/hpk/p/execnet/execnet/gateway_base.py", line 421, in send
self.gateway._send(Message.CHANNEL_DATA, self.id, dumps_internal(item))
File "/home/hpk/p/execnet/execnet/gateway_base.py", line 698, in _send
message.to_io(self._io)
File "/home/hpk/p/execnet/execnet/gateway_base.py", line 128, in to_io
io.write(header+self.data)
File "/home/hpk/p/execnet/execnet/gateway_base.py", line 98, in write
self._write(data)
IOError: [Errno 32] Broken pipe
>>>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment