Skip to content

Commit

Permalink
refactor: add reference to aiostomp instance
Browse files Browse the repository at this point in the history
  • Loading branch information
pedrokiefer committed Feb 6, 2019
1 parent 716e081 commit 48d422e
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion aiostomp/aiostomp.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ async def _reconnect(self):
else:
logger.error('All connections attempts failed.')
if self._on_error:
asyncio.ensure_future(self._on_error(ExceededRetryCount()), loop=self._loop)
asyncio.ensure_future(self._on_error(ExceededRetryCount(self)), loop=self._loop)
break

self._increment_retry_interval()
Expand Down
5 changes: 4 additions & 1 deletion aiostomp/errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,7 @@ class StompDisconnectedError(Exception):


class ExceededRetryCount(Exception):
pass

def __init__(self, ref):
super().__init__('Retry count exceeded!')
self.ref = ref
1 change: 1 addition & 0 deletions tests/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -534,6 +534,7 @@ async def test_reconnection_error(self, logger_mock):
logger_mock.error.assert_called_with(
'All connections attempts failed.')
self.assertIsInstance(self.stomp._on_error.call_args[0][0], ExceededRetryCount)
self.assertEqual(self.stomp._on_error.call_args[0][0].ref, self.stomp)

@unittest_run_loop
async def test_can_reconnect_on_connection_lost(self):
Expand Down

0 comments on commit 48d422e

Please sign in to comment.