edgedb-python
edgedb-python copied to clipboard
Cannot terminate from within transaction
import asyncio
import edgedb
async def main():
client = edgedb.create_async_client("_localdev")
async for tx in client.transaction():
async with tx:
print(await tx.query_single("SELECT 123"))
client.terminate()
await client.aclose()
asyncio.run(main())
This fails with:
123
Traceback (most recent call last):
File "test.py", line 14, in <module>
asyncio.run(main())
File "asyncio/runners.py", line 44, in run
return loop.run_until_complete(main)
File "asyncio/base_events.py", line 642, in run_until_complete
return future.result()
File "test.py", line 10, in main
client.terminate()
File "edgedb/asyncio_pool.py", line 595, in terminate
self._impl.terminate()
File "edgedb/asyncio_pool.py", line 473, in terminate
ch.terminate()
File "edgedb/asyncio_pool.py", line 201, in terminate
self._con.terminate()
File "edgedb/asyncio_con.py", line 501, in terminate
self._cleanup()
File "edgedb/asyncio_pool.py", line 68, in _cleanup
self._inner._holder._release_on_close()
File "edgedb/asyncio_pool.py", line 204, in _release_on_close
self._release()
File "edgedb/asyncio_pool.py", line 217, in _release
self._con = self._con._detach()
File "edgedb/asyncio_pool.py", line 56, in _detach
new_conn = self._shallow_clone()
File "edgedb/asyncio_con.py", line 216, in _shallow_clone
raise base_con.borrow_error(self._inner._borrowed_for)
File "edgedb/base_con.py", line 45, in borrow_error
raise errors.InterfaceError(BORROW_ERRORS[condition])
edgedb.errors.InterfaceError: Connection object is borrowed for a transaction. Use the methods on transaction object instead.
A more common use case is to wait on client.aclose() for some seconds, then CancellationError will trigger client.terminate() if some other coroutine is busy in a transaction.
Is this still an issue? I don't get this behavior now.
Right, it's fixed.