Type fixes

aio_explicit_task_cancels
Tyler Goodlet 2022-04-12 11:48:32 -04:00
parent 032e14e326
commit f3606d5bd8
1 changed files with 4 additions and 2 deletions

View File

@ -100,7 +100,7 @@ class LinkedTaskChannel(trio.abc.Channel):
self._to_aio.put_nowait(item) self._to_aio.put_nowait(item)
def closed(self) -> bool: def closed(self) -> bool:
return self._from_aio._closed return self._from_aio._closed # type: ignore
# TODO: shoud we consider some kind of "decorator" system # TODO: shoud we consider some kind of "decorator" system
# that checks for structural-typing compatibliity and then # that checks for structural-typing compatibliity and then
@ -289,8 +289,9 @@ def _run_asyncio_task(
# raise aio_err from err # raise aio_err from err
elif task_err is None: elif task_err is None:
assert aio_err
aio_err.with_traceback(aio_err.__traceback__) aio_err.with_traceback(aio_err.__traceback__)
msg = ''.join(traceback.format_exception(aio_err)) msg = ''.join(traceback.format_exception(type(aio_err)))
log.error( log.error(
f'infected task errorred:\n{msg}' f'infected task errorred:\n{msg}'
) )
@ -340,6 +341,7 @@ async def translate_aio_errors(
trio.Cancelled, trio.Cancelled,
): ):
# relay cancel through to called ``asyncio`` task # relay cancel through to called ``asyncio`` task
assert chan._aio_task
chan._aio_task.cancel( chan._aio_task.cancel(
msg=f'the `trio` caller task was cancelled: {trio_task.name}' msg=f'the `trio` caller task was cancelled: {trio_task.name}'
) )