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

Basic example gives an error #14

Open
Valeronlol opened this issue Jan 31, 2023 · 0 comments
Open

Basic example gives an error #14

Valeronlol opened this issue Jan 31, 2023 · 0 comments

Comments

@Valeronlol
Copy link

Valeronlol commented Jan 31, 2023

import asyncio
import aiocontext

context = aiocontext.Context()

async def print_request():
    print("Request ID:", context.get('request_id', 'unknown'))

async def handle_request():
    context['request_id'] = 42
    await print_request()

if __name__ == '__main__':
    loop = asyncio.get_event_loop()
    aiocontext.wrap_task_factory(loop)
    context.attach(loop)
    loop.run_until_complete(handle_request())

AttributeError: type object '_asyncio.Task' has no attribute 'current_task'
sys:1: RuntimeWarning: coroutine 'handle_request' was never awaited

Python version 3.10

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