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

asyncio.gather() on None #76

Open
wbenny opened this issue Mar 6, 2020 · 2 comments
Open

asyncio.gather() on None #76

wbenny opened this issue Mar 6, 2020 · 2 comments

Comments

@wbenny
Copy link
Contributor

wbenny commented Mar 6, 2020

Here https://github.com/mosquito/aiormq/blob/master/aiormq/connection.py#L439
... is this snippet of code:

        self._reader_task = None                                            # 1

        await asyncio.gather(
            self.__close_writer(writer), return_exceptions=True
        )

        await asyncio.gather(self._reader_task, return_exceptions=True)     # 2

self._reader_task is being set to None and then given to the asyncio.gather().
This obviously raises an exception:

  File "..\venv\lib\site-packages\aiormq\connection.py", line 445, in _on_close
    await asyncio.gather(self._reader_task, return_exceptions=True)
  File "..\lib\asyncio\tasks.py", line 806, in gather
    fut = ensure_future(arg, loop=loop)
  File "..\lib\asyncio\tasks.py", line 673, in ensure_future
    raise TypeError('An asyncio.Future, a coroutine or an awaitable is '
TypeError: An asyncio.Future, a coroutine or an awaitable is required

... which is usually conviniently and silently suppressed here: https://github.com/mosquito/aiormq/blob/master/aiormq/base.py#L139

        with suppress(Exception):
            await self._on_close(exc)
@wbenny
Copy link
Contributor Author

wbenny commented Mar 6, 2020

I believe this line doesn't belong there at all:

await asyncio.gather(self._reader_task, return_exceptions=True)

It was introduced here:
21860d5#diff-ad998bcf1174a988f9e7d57468f6f146R452

Is my understanding correct?

@wbenny
Copy link
Contributor Author

wbenny commented Mar 6, 2020

Okay, I looked closer at the diff and realized that lined does belong there, but it should be executed before the self._reader_task = None.

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

No branches or pull requests

1 participant