Skip to content
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

Hangs on subsequent connect, timeout ignored #463

Open
madduck opened this issue Dec 25, 2024 · 2 comments
Open

Hangs on subsequent connect, timeout ignored #463

madduck opened this issue Dec 25, 2024 · 2 comments

Comments

@madduck
Copy link

madduck commented Dec 25, 2024

Hello, I have to deal with a Microsoft Access "database" on the Windows "operating system". Yes, thank you for your sympathy.

I have aioodbc working to the point where I can get an async connection & cursor, execute a query, and fetch results. Once. If, within the same async app, I then try to create another connection to an Access "database", even if it's a different one (I copy it to a temporary file just to be sure), the app will hang awaiting the connection to happen. When this is the case, I need to cancel the app, which then results in this traceback:

  File "…\tptools\webserver.py", line 151, in load_tp_file
    async with aioodbc.connect(
               ^^^^^^^^^^^^^^^^
  File "…\site-packages\aioodbc\utils.py", line 86, in __aenter__
    self._obj = await self._coro
                ^^^^^^^^^^^^^^^^
  File "…\site-packages\aioodbc\connection.py", line 277, in _connect
    await conn._connect()
  File "…\site-packages\aioodbc\connection.py", line 81, in _connect
    self._conn = await f
                 ^^^^^^^
  File "…\Lib\concurrent\futures\thread.py", line 59, in run
    result = self.fn(*self.args, **self.kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
pyodbc.Error: ('HY000', 'The driver did not supply an error!')

as you can see, the code is awaiting the connection when it gets cancelled. It doesn't matter how long I wait before I Ctrl-C my way out of the code.

Also, I did set timeout=10 on the connect() call, but that does not seem to do anything, at least not in this context.

This is the DSN I used:

DRIVER={Microsoft Access Driver (*.mdb, *.accdb)};DBQ=C:\Users\martin\AppData\Local\Temp\TP2jsonuqc7y660\Demo.tp;Pwd=d4R2GY76w2qzZ

As I said, it works once always, sometimes twice, I've even seen it work 5 times in a row — the code is triggered whenever the database file's mtime changes — but eventually, it will hang.

Of course, if I turn tracing on in the Windows ODBC manager, the problem never happens. So this looks like a race condition of sorts, on this quality "operating system" with this quality "database".

Any clues?

PS: I tried to make a test case, but the database is sensitive. If I use a test database, that is a bit smaller, I cannot reproduce the problem.

@madduck
Copy link
Author

madduck commented Dec 25, 2024

As a further piece of information, trying to use asyncio.timeout or asyncio.wait_for do not change the behaviour:

conn = await asyncio.wait_for(aioodbc.connect(dsn=connstr), timeout=10)

… this will run indefinitely, until I ctrl-c my way out, then we get the exact same above traceback.

@madduck
Copy link
Author

madduck commented Dec 25, 2024

Also note that I have not been able to reproduce this problem with pyodbc synchronously, i.e. with pyodbc, I can load the same database a million times in a row without problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant