Thank you for the straightforward explanation. May I ask you another question? I don't understand the behavior of this waiting primitive. So here is the case below: ```py import asyncio
e = KeyboardInterrupt # or SystemExit async def sub_task(): raise e async def main_task(): try: await asyncio.gather( # -- aws -- sub_task(), asyncio.sleep(0) ) except Exception as e: print('\tmain_task(), e:', repr(e)) raise except BaseException as e: print('\tmain_task(), be:', repr(e)) if __name__ == '__main__': try: asyncio.run(main_task()) except e: print(f'__main__ {e}') ``` When one coroutine `[sub_task()]`, result is: main_task(), be: CancelledError() __main__ <class 'KeyboardInterrupt'> When two coroutines `[sub_task(), sleep(0)]` , result is: main_task(), be: KeyboardInterrupt() __main__ <class 'KeyboardInterrupt'> Why are results so different when `aws` contains single coroutine or two coroutines ? Thank for your time Yves Guido van Rossum wrote: > KeyboardInterrupt is generally not handled properly by asyncio, the normal > behavior here is that the code just exits with a traceback. > On Tue, Jun 7, 2022 at 11:00 AM Yves Duprat ydup...@gmail.com wrote: > > Hi, > > regarding this [issue93122](https://github.com/python/cpython/issues/93122), > > I am wondering what is the normal behavior of `asyncio.gather` when one of > > the submitted tasks raises a `KeyboardInterrupt` exception ? -- regardless > > of the value of the `return_exception` parameter. > > It seems that this primitive does not behave the same way with > > `KeyboardInterrupt` and `ZeroDivisionError` exceptions. But may be it is > > normal ? > > I have searched in the documentation [here]( > > https://docs.python.org/3/library/asyncio-task.html#asyncio.gather) but I > > did not find anything. > > Thanks for your help. > > Yves > > _______________________________________________ > > Python-Dev mailing list -- python-dev@python.org > > To unsubscribe send an email to python-dev-le...@python.org > > https://mail.python.org/mailman3/lists/python-dev.python.org/ > > Message archived at > > https://mail.python.org/archives/list/python-dev@python.org/message/5KVY7SSD... > > Code of Conduct: http://python.org/psf/codeofconduct/ > > -- > --Guido van Rossum (python.org/~guido) > *Pronouns: he/him **(why is my pronoun here?)* > http://feministing.com/2015/02/03/how-using-they-as-a-singular-pronoun-can-change-the-world/ _______________________________________________ Python-Dev mailing list -- python-dev@python.org To unsubscribe send an email to python-dev-le...@python.org https://mail.python.org/mailman3/lists/python-dev.python.org/ Message archived at https://mail.python.org/archives/list/python-dev@python.org/message/5AHMYI246S6INVUNPJM3KTM2XCRHYNDD/ Code of Conduct: http://python.org/psf/codeofconduct/