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

RuntimeError in aiohttp's TimerContext with 0.11.0 #158

Closed
ods opened this issue Apr 27, 2020 · 1 comment · Fixed by #156
Closed

RuntimeError in aiohttp's TimerContext with 0.11.0 #158

ods opened this issue Apr 27, 2020 · 1 comment · Fixed by #156

Comments

@ods
Copy link

ods commented Apr 27, 2020

Minimal example to reproduce:

from aiohttp.client import ClientSession
import pytest


@pytest.fixture
async def session():
    session = ClientSession()
    yield session
    await session.close()


@pytest.mark.asyncio
async def test_aiohttp(session):
    async with session.get('http://example.com/') as response:
        pass

The test output:

============================================= FAILURES =============================================
___________________________________________ test_aiohttp ___________________________________________
Traceback (most recent call last):
  File "/usr/src/tests/test_aiohttp.py", line 16, in test_aiohttp
    async with session.get('http://example.com/') as response:
  File "/usr/local/lib/python3.7/site-packages/aiohttp/client.py", line 1012, in __aenter__
    self._resp = await self._coro
  File "/usr/local/lib/python3.7/site-packages/aiohttp/client.py", line 426, in _request
    with timer:
  File "/usr/local/lib/python3.7/site-packages/aiohttp/helpers.py", line 579, in __enter__
    raise RuntimeError('Timeout context manager should be used '
RuntimeError: Timeout context manager should be used inside a task
===================================== short test summary info ======================================
FAILED tests/test_aiohttp.py::test_aiohttp - RuntimeError: Timeout context manager should be used...
======================================== 1 failed in 0.17s =========================================

Works fine with 0.10.0 or when session is created directly in the test instead of fixture.

@simonfagerholm
Copy link
Contributor

Same root cause as #154 and #157, tested the example with #156 and it works.

Cito added a commit to graphql-python/aiohttp-graphql that referenced this issue May 3, 2020
Version 0.11 has an issue that causes us trouble, see
pytest-dev/pytest-asyncio#158
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 a pull request may close this issue.

2 participants