Skip to content
New issue

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

Fix support for python 3.9 #5

Open
wants to merge 1 commit into
base: default
Choose a base branch
from

Conversation

danielnelson
Copy link

I have been using taskgroup for Python versions 3.9 and 3.10, it works quite well. I have run into one issue with the latest 0.0.0a4 release on PyPI, I get this error in some situations during cancel:

Traceback (most recent call last):
  ... snip ...
  File "/usr/lib/python3.9/asyncio/tasks.py", line 413, in wait
    return await _wait(fs, timeout, return_when, loop)
  File "/usr/lib/python3.9/asyncio/tasks.py", line 525, in _wait
    await waiter
asyncio.exceptions.CancelledError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.9/unittest/async_case.py", line 64, in _callTestMethod
    self._callMaybeAsync(method)
  File "/usr/lib/python3.9/unittest/async_case.py", line 87, in _callMaybeAsync
    return self._asyncioTestLoop.run_until_complete(fut)
  File "/usr/lib/python3.9/asyncio/base_events.py", line 647, in run_until_complete
    return future.result()
  File "/usr/lib/python3.9/unittest/async_case.py", line 101, in _asyncioLoopRunner
    ret = await awaitable
  ... snip ...
  File "/home/dbn/usr/py-3.9/lib/python3.9/site-packages/taskgroup/taskgroups.py", line 71, in __aexit__
    if self._parent_cancel_requested and not self._parent_task.uncancel():
AttributeError: '_asyncio.Task' object has no attribute 'uncancel'

I noticed that HEAD has this fixed, to get it to work with Python 3.9 I just needed to switch some type annotations back to the Python 3.9 style, using Union and Optional.

@Gobot1234
Copy link
Contributor

The better IMO way to fix this is to use __future__.annotations

This allows using newer annotation feature while still supporting Python
3.9.
@danielnelson
Copy link
Author

That's a good idea, I have updated the PR to use this method.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants