Le mardi 17 décembre 2013 12:27:48 UTC+1, Antoine Pitrou a écrit :
>
> Actually, the general pattern may be to call self.transport.reconnect() 
> from the protocol's connection_lost(). 
>

Yes, it would be very useful to have a reconnect method on the transport,  
I was trying something like calling the following coroutine in the 
connection_lost:


def reconnect():
  info = transport.get_extra_info('peername')
  loop = asyncio.get_event_loop()
  transport, protocol = yield from loop.create_connection(lambda: self, 
*info)
  self.transport = transport

This will probably work, but makes an assumption on which kind of transport 
the protocol is using. What if this is a unix socket instead of a TCP 
socket. Does the get_extra_info return what needs to be passed into 
create_connection?

I'd like any of the following:

  transport.reconnect()
or
  new_transport = transport.reconnect(protocol_instance)

Reply via email to