Skip to content

Commit

Permalink
Adaptions for Python 3.8.
Browse files Browse the repository at this point in the history
  • Loading branch information
eerimoq committed Jan 2, 2020
1 parent f31daed commit c116969
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ language: python

python:
- "3.7"
- "3.8"

install:
- pip install coveralls
Expand Down
14 changes: 7 additions & 7 deletions mqttools/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ async def start(self, resume_session=False):
break
except SessionResumeError:
raise
except Exception as e:
except (Exception, asyncio.CancelledError) as e:
if isinstance(e, ConnectionRefusedError):
LOGGER.info('TCP connect refused.')
elif isinstance(e, TimeoutError):
Expand Down Expand Up @@ -370,7 +370,7 @@ async def _start(self, resume_session=False):
if not resume_session or not session_present:
for topic in self._subscriptions:
await self.subscribe(topic)
except Exception:
except (Exception, asyncio.CancelledError):
await self.stop()
raise

Expand All @@ -390,23 +390,23 @@ async def stop(self):

try:
self.disconnect()
except Exception:
except (Exception, asyncio.CancelledError):
pass

if self._reader_task is not None:
self._reader_task.cancel()

try:
await self._reader_task
except Exception:
except (Exception, asyncio.CancelledError):
pass

if self._keep_alive_task is not None:
self._keep_alive_task.cancel()

try:
await self._keep_alive_task
except Exception:
except (Exception, asyncio.CancelledError):
pass

if self._writer is not None:
Expand Down Expand Up @@ -630,7 +630,7 @@ async def _reader_main(self):

try:
await self.reader_loop()
except Exception as e:
except (Exception, asyncio.CancelledError) as e:
LOGGER.info('Reader task stopped by %r.', e)

if isinstance(e, MalformedPacketError):
Expand Down Expand Up @@ -658,7 +658,7 @@ async def _keep_alive_main(self):

try:
await self.keep_alive_loop()
except Exception as e:
except (Exception, asyncio.CancelledError) as e:
LOGGER.info('Keep alive task stopped by %r.', e)
await self._close()

Expand Down

0 comments on commit c116969

Please sign in to comment.