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

async callback are not supported #38

Closed
mkotsalainen opened this issue Mar 18, 2021 · 4 comments
Closed

async callback are not supported #38

mkotsalainen opened this issue Mar 18, 2021 · 4 comments
Assignees
Labels
question Further information is requested

Comments

@mkotsalainen
Copy link

When I register an async function as a callback to httpx_mock I get this error:
TypeError: cannot unpack non-iterable coroutine object

I suppose it's not awaited here:
https://github.com/Colin-b/pytest_httpx/blob/develop/pytest_httpx/_httpx_mock.py#L179

Is this a bug or am I using the library wrong?

Thanks!

@mkotsalainen mkotsalainen changed the title Async function as dynamic response blow up Async function as dynamic response blows up Mar 18, 2021
@Colin-b
Copy link
Owner

Colin-b commented Mar 18, 2021

Hello @mkotsalainen ,

The callback is not supposed to be async.
Is there a reason why you would need this?

Best Regards

@Colin-b Colin-b self-assigned this Mar 18, 2021
@Colin-b Colin-b added the question Further information is requested label Mar 18, 2021
@Colin-b Colin-b changed the title Async function as dynamic response blows up async callback are not supported Mar 18, 2021
@mkotsalainen
Copy link
Author

Ok I see. I had test where I was concurrently doing some things via async.gather. One of them was a httpx call. My plan was to use asyncio.sleep in the mock response function. I could probably work around it by using normal sleep there instead. Thanks for a great util!

@Colin-b
Copy link
Owner

Colin-b commented Mar 18, 2021

Sure, if the non-async way does not fit your use case do not hesitate to ask for a feature.

Thanks for the nice word :)

@Colin-b
Copy link
Owner

Colin-b commented Oct 20, 2022

Hello @mkotsalainen, Release 0.21.1 is now available on pypi and allows you to register async callbacks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants