something wrong in my app with error "close cannot be used while an asynchronous query is underway"
See original GitHub issueRenctly I tried to redeploy my project used with sanic frame ,some errors happened when I do a test under high-concurrency. info in the log:
close cannot be used while an asynchronous query is underway
and the traceback is below:
Traceback (most recent call last):
File "/home/mwh/ad_sanic/handlers/oprs.py", line 17, in post
_parsed_req = await ReqParser(_req_body,'parse',req_ip=(request.headers['Remote-Addr']).split(':')[0]).parser()
File "/home/mwh/ad_sanic/utils/req_parse.py", line 49, in parser
_mapped['sim_country_iso'] = await self.geo()
File "/home/mwh/ad_sanic/utils/req_parse.py", line 75, in geo
db_country = (await self.db.get(DbIp.select(DbIp.country).where((DbIp.ip_from<=self._req_ip)&(DbIp.ip_to>=self._req_ip)))).country
File "/home/mwh/py3.5_virtuanlenv/lib/python3.5/site-packages/peewee_async.py", line 169, in get
result = yield from self.execute(query.limit(1))
File "/home/mwh/py3.5_virtuanlenv/lib/python3.5/site-packages/peewee_async.py", line 269, in execute
return (yield from execute(query))
File "/home/mwh/py3.5_virtuanlenv/lib/python3.5/site-packages/peewee_async.py", line 428, in execute
return (yield from coroutine(query))
File "/home/mwh/py3.5_virtuanlenv/lib/python3.5/site-packages/peewee_async.py", line 569, in select
cursor = yield from _execute_query_async(query)
File "/home/mwh/py3.5_virtuanlenv/lib/python3.5/site-packages/peewee_async.py", line 1491, in _execute_query_async
return (yield from _run_sql(query.database, *query.sql()))
File "/home/mwh/py3.5_virtuanlenv/lib/python3.5/site-packages/peewee_async.py", line 1476, in _run_sql
cursor = yield from database.cursor_async()
File "/home/mwh/py3.5_virtuanlenv/lib/python3.5/site-packages/peewee_async.py", line 902, in cursor_async
return (yield from self._async_conn.cursor(conn=conn))
File "/home/mwh/py3.5_virtuanlenv/lib/python3.5/site-packages/peewee_async.py", line 1067, in cursor
conn = yield from self.acquire()
File "/home/mwh/py3.5_virtuanlenv/lib/python3.5/site-packages/peewee_async.py", line 1036, in acquire
return (yield from self.pool.acquire())
File "/home/mwh/py3.5_virtuanlenv/lib/python3.5/site-packages/aiopg/utils.py", line 67, in __iter__
resp = yield from self._coro
File "/home/mwh/py3.5_virtuanlenv/lib/python3.5/site-packages/aiopg/pool.py", line 180, in _acquire
yield from self._cond.wait()
File "/usr/local/lib/python3.5/asyncio/locks.py", line 326, in wait
yield from fut
File "/usr/local/lib/python3.5/asyncio/futures.py", line 385, in __iter__
yield self # This tells Task to wait for completion.
File "uvloop/future.pyx", line 434, in uvloop.loop.BaseTask._fast_wakeup (uvloop/loop.c:112710)
File "/usr/local/lib/python3.5/asyncio/futures.py", line 266, in result
raise CancelledError
concurrent.futures._base.CancelledError
what caused this problem?
Issue Analytics
- State:
- Created 7 years ago
- Reactions:8
- Comments:6 (1 by maintainers)
Top Results From Across the Web
ERROR: Execute cannot be used while an asynchronous ...
It happens a lot when auto-suggest is on. To switch off autocomplete go to File > Preferences > Query Tool > Auto Completion...
Read more >execute cannot be used while an asynchronous query is ...
ERROR : execute cannot be used while an asynchronous query is underway. reproduce step: 1. open a query tool for any database in...
Read more >close cannot be used while an asynchronous query is underway
the problem is that self._weak = weakref.ref(self, lambda wr: cursor.close()) try to close the connection when a query is underway (as you read ......
Read more >DatabaseError: execute used with asynchronous query
DatabaseError : execute cannot be used while an asynchronous query is underway. I can't seem to reproduce the error, it's never happened before,...
Read more >Asynchronous Query Execution - Devart
Later, when the query has finished its execution, application calls the "End" method, passing it IAsyncResult object returned by the "Begin" method that...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I was getting this same issue.
peewee.ProgrammingError: close cannot be used while an asynchronous query is underway
After tracing through the issue, I determined it was due to my setup with pytest-asyncio since that library does the following in the default event_loop fixture:
To fix the issue, I created a conftest.py file at the root of my tests that has the following replacement fixture.
Maybe this will help someone else who lands here from google.
I get this while performing unit tests.
I have a series of simple tests to grab an entity with a simple manager context query. If I try to execute more than one during a test, I get this error.