-
Notifications
You must be signed in to change notification settings - Fork 96
Closed
Labels
Description
- What versions are you using?
Oracle Database 19c
platform.platform: Windows-10-10.0.19045-SP0
sys.maxsize > 2**32: True
platform.python_version: 3.12.3
oracledb.version: 2.2.0
-
Is it an error or a hang or a crash?
It is a hang. -
What error(s) or behavior you are seeing?
If many connections open semultaneously then await on AsyncConnection freezes forever.
- Does your application call init_oracle_client()?
No, it's Thin mode.
- Include a runnable Python script that shows the problem.
import oracledb
import asyncio
oracledb.defaults.config_dir = ' '
u = ' '
p = ' '
async def c(u, p, dsn):
print('start')
connection = await oracledb.connect_async(user=u,
password=p,
dsn=dsn)
print('end')
async def main():
asyncio.create_task(c(u, p, ' '))
asyncio.create_task(c(u, p, ' '))
await asyncio.sleep(3)
if __name__ == '__main__':
asyncio.run(main())
Addition of Async.Lock synchronization solves the problem.
import oracledb
import asyncio
oracledb.defaults.config_dir = ' '
u = ' '
p = ' '
async def c(u, p, dsn, l):
print('start')
async with l:
connection = await oracledb.connect_async(user=u,
password=p,
dsn=dsn)
print('end')
async def main():
l = asyncio.Lock()
asyncio.create_task(c(u, p, ' ', l))
asyncio.create_task(c(u, p, ' ', l))
await asyncio.sleep(3)
if __name__ == '__main__':
asyncio.run(main())