Feature or enhancement
Proposal:
Abstract
Sometimes there might be a case when a block inside async with asyncio.timeout(10) can raise TimeoutError and there are no proper way to identify one TimeoutError from another.
async with asyncio.timeout(10):
if ...:
raise TimeoutError
then here engineers will not be able to identify from where TimeoutError was received
Simplest example
import asyncio
async def main():
try:
async with asyncio.timeout(1):
raise TimeoutError
except asyncio.TimeoutError: # will catch both, but should only exception from asyncio.timeout
print('catched asyncio.TimeoutError')
asyncio.run(main())
More complex example
try:
async with asyncio.timeout(10):
if ...:
raise TimeoutError
except TimeoutError: # will catch both
pass
except asyncio.TimeoutError: # will catch both, but should only exception from asyncio.timeout
pass
Proposal
asyncio should raise asyncio.TimeoutError from asyncio.exceptions and use some kind of inheritance, e.g.
class TimeoutError(builtins.TimeoutError):
pass
then engineers will be able to use native TimeoutError from builtins as well as asyncio.TimeoutError for their try/except or isinstance checks.
Has this already been discussed elsewhere?
This is a minor feature, which does not need previous discussion elsewhere
Links to previous discussion of this feature:
No response
Linked PRs
Feature or enhancement
Proposal:
Abstract
Sometimes there might be a case when a block inside
async with asyncio.timeout(10)can raise TimeoutError and there are no proper way to identify one TimeoutError from another.then here engineers will not be able to identify from where TimeoutError was received
Simplest example
More complex example
Proposal
asyncio should raise asyncio.TimeoutError from asyncio.exceptions and use some kind of inheritance, e.g.
then engineers will be able to use native TimeoutError from builtins as well as asyncio.TimeoutError for their try/except or isinstance checks.
Has this already been discussed elsewhere?
This is a minor feature, which does not need previous discussion elsewhere
Links to previous discussion of this feature:
No response
Linked PRs
TimeoutErrors unique rather than aliases #124320