Skip to content

Commit

Permalink
Stop raising asyncio.CancelledError if the connection is already clos…
Browse files Browse the repository at this point in the history
…ed (slackapi#1152)

* Update async_client.py
* Update slack_sdk/socket_mode/async_client.py

Co-authored-by: Kazuhiro Sera <[email protected]>
  • Loading branch information
mattvonarx and seratch authored Jan 21, 2022
1 parent 2dee665 commit afa40ea
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions slack_sdk/socket_mode/async_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,11 @@ async def process_messages(self):
while not self.closed:
try:
await self.process_message()
except asyncio.CancelledError:
# if self.closed is True, the connection is already closed
# In this case, we can ignore the exception here
if not self.closed:
raise
except Exception as e:
self.logger.exception(
f"Failed to process a message: {e}, session: {session_id}"
Expand Down

0 comments on commit afa40ea

Please sign in to comment.