Commit 49542a20 authored by dieter's avatar dieter

fix `create_connection` callback

parent 243909ce
...@@ -122,15 +122,18 @@ class Protocol(base.Protocol): ...@@ -122,15 +122,18 @@ class Protocol(base.Protocol):
cr = self.loop.create_unix_connection( cr = self.loop.create_unix_connection(
self.protocol_factory, self.addr, ssl=self.ssl) self.protocol_factory, self.addr, ssl=self.ssl)
# an ``asyncio.Future``
self._connecting = cr = asyncio.ensure_future(cr, loop=self.loop) self._connecting = cr = asyncio.ensure_future(cr, loop=self.loop)
@cr.add_done_callback @cr.add_done_callback
def done_connecting(future): def done_connecting(future):
if future.exception() is not None: try:
logger.info("Connection to %r failed, retrying, %s", future.exception()
self.addr, future.exception()) except Exception:
logger.exception("Connection to %r failed", self.addr)
# keep trying # keep trying
if not self.closed: if not self.closed:
logger.info("retry connecting %r", self.addr)
self.loop.call_later( self.loop.call_later(
self.connect_poll + local_random.random(), self.connect_poll + local_random.random(),
self.connect, self.connect,
...@@ -410,10 +413,7 @@ class Client(object): ...@@ -410,10 +413,7 @@ class Client(object):
def _clear_protocols(self, protocol=None): def _clear_protocols(self, protocol=None):
for p in self.protocols: for p in self.protocols:
if p is not protocol: if p is not protocol:
try:
p.close() p.close()
except asyncio.CancelledError:
continue
self.protocols = () self.protocols = ()
def disconnected(self, protocol=None): def disconnected(self, protocol=None):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment