Skip to content

Commit be5c733

Browse files
Handle asyncio.CancelledError (#88)
* Handle asyncio.CancelledError * Moved where CancelledError Exception is handled Needed for 3.8+ compatbility as CancelledError was changed from an Exception to a BaseException Co-authored-by: Youri Bonnaffe <youri.bonnaffe@symphony.com>
1 parent 2d4e3c5 commit be5c733

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

sym_api_client_python/datafeed_event_service.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
import datetime
66
from collections import namedtuple
77

8+
from asyncio import CancelledError
9+
810
#TODO: These imports are duplicated over the abstract class to avoid errors in the Async version
911
from .exceptions.UnauthorizedException import UnauthorizedException
1012
from .exceptions.APIClientErrorException import APIClientErrorException
@@ -232,7 +234,10 @@ async def read_datafeed(self):
232234
while not self.stop:
233235
try:
234236
events = await self.datafeed_client.read_datafeed_async(self.datafeed_id)
235-
237+
except CancelledError as exc:
238+
log.info("Cancel request received. Stopping datafeed...")
239+
await self.deactivate_datafeed()
240+
raise
236241
except Exception as exc:
237242
try:
238243
await self.handle_datafeed_errors(exc)

0 commit comments

Comments
 (0)