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

Pytest hangs with scope='session' async fixture #642

Open
snb2013 opened this issue Aug 15, 2024 · 0 comments
Open

Pytest hangs with scope='session' async fixture #642

snb2013 opened this issue Aug 15, 2024 · 0 comments

Comments

@snb2013
Copy link

snb2013 commented Aug 15, 2024

Checklist

  • [v] I have included information about relevant versions
  • [v] I have verified that the issue persists when using the master branch of Faust.

Steps to reproduce

When using async fixtures with scope='session', test hangs.
Minimal example.

from asyncio import get_event_loop, sleep
import pytest

import faust

app = faust.App('example')

@app.agent()
async def bar(stream):
    async for value in stream:
        yield value

@pytest.fixture(scope='session')
def event_loop():
    loop = get_event_loop()
    yield loop

@pytest.fixture(scope='session')
async def session_ficture():
    await sleep(0)
    yield 1

@pytest.fixture(scope='function')
async def function_ficture():
    await sleep(0)
    yield 2

async def test_good(function_ficture):
    async with bar.test_context() as agent:
        await agent.put('hey')

async def test_hangs(session_ficture):
    async with bar.test_context() as agent:
        await agent.put('hey')

pytest.ini content:
[pytest]
asyncio_mode=auto

Expected behavior

Tests should not be hanged.

Actual behavior

Test 'test_hangs' is hanged.

Versions

  • Python version 3.12
  • Faust version 0.11.2
  • Operating system Ubuntu 23.04
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