-
Notifications
You must be signed in to change notification settings - Fork 404
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
asyncpg.exceptions._base.InterfaceError: cannot perform operation: another operation is in progress #56
Comments
I'm not sure your snippet is complete. Where does Thanks. |
Hi, this code is simple clearly, and it was connected database, just use asyncpg to create_pool .
|
@yjdwbj, you'll have to pass the loop into sanic manually.
|
@yjdwbj why closed?I met the same problem |
@cctse Because the authors not care this bugs.I found openresty instead of it. |
@elprans please reopen this issue, full code as follows
error when curl http://127.0.0.1:8084
|
@cctse what version of sanic are you using? It still looks like asyncpg and sanic are running a different loops. |
@amsb |
Hey guys, I'm one of the maintainers of Sanic. Is there no way to pass a loop to asyncpg? You could use a server event to pass the loop sanic creates to asyncpg and establish the db connection like so. |
We even have an asyncpg example on our main repo: https://github.com/channelcat/sanic/blob/master/examples/sanic_asyncpg_example.py |
Both create_pool and Connection accept loop as argument. |
That's what I thought. So it's really a non-issue here. Just a confusion on implementation. |
Hey @seemethere, there was a time where The problem maybe lies in the uvloop library?
|
@jbcurtin Passing a loop was deprecated because event loops cannot be forked which makes it impossible to fully support multiprocessing. As of python 3.6 |
Yes, I'm aware of those limitations. Take a look at the following... I solved this by creating a GLOBAL setting that I run all my logic from. Sure, its a pain to manage, but I was able to move forward and fork the processes.
Unfortunately, the deprecation of |
hi @elprans ,
async def db_coro(request):
stmt= request.app['sql_prepared_stmt']
print( await stmt.fetchval('Bob') ) Server main code: if __name__ == '__main__':
#Some simplecode for running simple aiohttp server
app['sql_prepared_stmt'] = await conn.prepare('SELECT sid FROM test_tble WHERE name = $1 AND sid NOTNULL AND sid >5')
#Some simplecode for running simple aiohttp server |
@Behzad-S seems like you are using a shared connection and are attempting to run queries concurrently on it. Use |
I am getting this issue with fastapi when i try to use asyncpg with asynio.gather |
@gary-x0pa can you paste the coroutines code which you are running using asyncio.gather? I also faced the same issue using gino(with asyncpg driver). The issue for me was acquiring db connection with To elaborate, the tasks which I ran using asyncio.gather had code Acquiring connections with reuse=False fixed it for me. For reference python-gino/gino#313 |
Hmm i didnt put any argument when acquiring. I circumvented the issue by just manually awaiting each coroutine. |
I have run into a similar problem using FastAPI and asyncpg connections pool. I have written a comment in this most relevant issue fastapi/fastapi#1800 with a reference to the solution I found. |
Hi, here is my code ,please help resovle the problem.thanks a lot.
The text was updated successfully, but these errors were encountered: