We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Hi Matt!
It is probably better to include the following line in the finally block to confirm whether the task was cancelled:
finally
print(f'Was the task cancelled? {delay_task.cancelled()}')
This ensures that you can accurately determine whether the task has been cancelled, especially when users manipulate the time values in the code.
async def main(): delay_task = asyncio.create_task(delay(2)) try: result = await asyncio.wait_for(delay_task, timeout=1) print(result) except asyncio.exceptions.TimeoutError: print('Got a timeout!') finally: print(f'Was the task cancelled? {delay_task.cancelled()}')
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Hi Matt!
It is probably better to include the following line in the
finally
block to confirm whether the task was cancelled:This ensures that you can accurately determine whether the task has been cancelled, especially when users manipulate the time values in the code.
The text was updated successfully, but these errors were encountered: