processors(frame_processors): add a try/except when cancelling tasks
This seems necessary because of how pytest works. If a task is cancelled, pytest will know the task has been cancelled even if # `asyncio.CancelledError` is handled internally in the task.
This commit is contained in:
@@ -311,8 +311,15 @@ class FrameProcessor:
|
|||||||
self.__push_frame_task = self.get_event_loop().create_task(self.__push_frame_task_handler())
|
self.__push_frame_task = self.get_event_loop().create_task(self.__push_frame_task_handler())
|
||||||
|
|
||||||
async def __cancel_push_task(self):
|
async def __cancel_push_task(self):
|
||||||
self.__push_frame_task.cancel()
|
try:
|
||||||
await self.__push_frame_task
|
self.__push_frame_task.cancel()
|
||||||
|
await self.__push_frame_task
|
||||||
|
except asyncio.CancelledError:
|
||||||
|
# TODO(aleix: Investigate why this is really needed. So far, this is
|
||||||
|
# necessary because of how pytest works. If a task is cancelled,
|
||||||
|
# pytest will know the task has been cancelled even if
|
||||||
|
# `asyncio.CancelledError` is handled internally in the task.
|
||||||
|
pass
|
||||||
|
|
||||||
async def __push_frame_task_handler(self):
|
async def __push_frame_task_handler(self):
|
||||||
running = True
|
running = True
|
||||||
|
|||||||
Reference in New Issue
Block a user