Skip to content

Hangs on subsequent connect, timeout ignored #463

@madduck

Description

@madduck

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions