Skip to content

Concurrent open of connections don't work on 2.2.0 and 2.2.1 also (operation takes forever) #353

@golubovai

Description

@golubovai
  1. 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

  1. Is it an error or a hang or a crash?
    It is a hang.

  2. What error(s) or behavior you are seeing?

If many connections open semultaneously then await on AsyncConnection freezes forever.

  1. Does your application call init_oracle_client()?
    No, it's Thin mode.
  1. 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())

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions