Skip to content

Commit

Permalink
refactor: reconnect with username and password
Browse files Browse the repository at this point in the history
  • Loading branch information
pedrokiefer committed Mar 26, 2018
1 parent 75dd4c1 commit bfcfa66
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions aiostomp/aiostomp.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,15 @@ async def connect(self, username=None, password=None):
await self._protocol.connect(username=username, password=password)
except (asyncio.TimeoutError, ConnectionRefusedError, OSError, asyncio.CancelledError) as exp:
logger.debug(exp)
asyncio.ensure_future(self.reconnect())
asyncio.ensure_future(self.reconnect(username=username, password=password))
return

self._connected = True
self._reconnect_attempts = 0
for subscription in self._subscriptions.values():
self._protocol.subscribe(subscription)

async def reconnect(self):
async def reconnect(self, username=None, password=None):
if self._reconnect_max_attempts == -1 or \
self._reconnect_attempts < self._reconnect_max_attempts:

Expand All @@ -68,7 +68,7 @@ async def reconnect(self):

async with timeout(self._reconnect_timeout):
logger.debug('reconnect attempt %s' % self._reconnect_attempts)
await self.connect()
await self.connect(username=username, password=password)
else:
logger.error('All connections attempts failed.')

Expand Down

0 comments on commit bfcfa66

Please sign in to comment.