crossbario / crossbario/autobahn-python

nicely_exit doesn't exit nicely with python >=3.7

Open
#1,430 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
2.5k
Forks
768
PR merge metrics
No merged PRs in 30d

Description

From Python 3.7, asyncio.Task.all_tasks() has been moved to asyncio.all_tasks() and asyncio.Task.current_task() has moved to asyncio.current_task()

Therefore, nicely_exit of autobahn/asyncio/component.py doesn't exit so nicely anymore

    @asyncio.coroutine
    def nicely_exit(signal):
        log.info("Shutting down due to {signal}", signal=signal)

        tasks = asyncio.Task.all_tasks()
        for task in tasks:
            # Do not cancel the current task.
            if task is not asyncio.Task.current_task():
                task.cancel()

and throws the following exception

AttributeError: type object '_asyncio.Task' has no attribute 'all_tasks'

Python >= 3.7
Autobahn 20.7.1

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in autobahn/asyncio/component.py at the nicely_exit function referenced in the issue. Check the asyncio task APIs used there against Python 3.7 and verify that shutdown completes without the reported AttributeError. Done means nicely_exit handles Python 3.7 and later without raising this exception.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
backend
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.