Skip to content

[1.4] The asyncio extension requires an async driver to be used. The loaded 'psycopg2' is not async. #6044

Closed

Description

@Dreamsorcerer

I'm now getting:

aiohttp: Traceback (most recent call last):
aiohttp:   File "/usr/local/lib/python3.8/site-packages/aiohttp/worker.py", line 57, in run
aiohttp:     self.loop.run_until_complete(self._task)
aiohttp:   File "uvloop/loop.pyx", line 1456, in uvloop.loop.Loop.run_until_complete
aiohttp:   File "/usr/local/lib/python3.8/site-packages/aiohttp/worker.py", line 84, in _run
aiohttp:     await runner.setup()
aiohttp:   File "/usr/local/lib/python3.8/site-packages/aiohttp/web_runner.py", line 275, in setup
aiohttp:     self._server = await self._make_server()
aiohttp:   File "/usr/local/lib/python3.8/site-packages/aiohttp/web_runner.py", line 375, in _make_server
aiohttp:     await self._app.startup()
aiohttp:   File "/usr/local/lib/python3.8/site-packages/aiohttp/web_app.py", line 416, in startup
aiohttp:     await self.on_startup.send(self)
aiohttp:   File "/usr/local/lib/python3.8/site-packages/aiohttp/signals.py", line 34, in send
aiohttp:     await receiver(*args, **kwargs)  # type: ignore
aiohttp:   File "/usr/local/lib/python3.8/site-packages/aiohttp/web_app.py", line 534, in _on_startup
aiohttp:     await it.__anext__()
aiohttp:   File "/aiohttp/app/main.py", line 51, in db_ctx
aiohttp:     engine = create_async_engine(dsn, future=True, pool_size=max_size)
aiohttp:   File "/usr/local/lib/python3.8/site-packages/sqlalchemy/ext/asyncio/engine.py", line 41, in create_async_engine
aiohttp:     return AsyncEngine(sync_engine)
aiohttp:   File "/usr/local/lib/python3.8/site-packages/sqlalchemy/ext/asyncio/engine.py", line 531, in __init__
aiohttp:     raise exc.InvalidRequestError(
aiohttp: sqlalchemy.exc.InvalidRequestError: The asyncio extension requires an async driver to be used. The loaded 'psycopg2' is not async.

The only relevant change is changing the version from beta1 to beta3. So, not sure if something broke in the latest beta?

Full results and PR at:
https://github.com/TechEmpower/FrameworkBenchmarks/pull/6446/checks?check_run_id=2106345525#step:9:9354

Activity

  1. added
    requires triage
    on Mar 14, 2021
  2. CaselIT commented on Mar 14, 2021

    @CaselIT
    Member

    Hi,

    that is expected. psyncpg2 is not an async driver. Please use asyncpg if you want to use asyncio with postgresql.

  3. added
    expected behavior
    and removed
    requires triage
    on Mar 14, 2021
  4. Dreamsorcerer commented on Mar 14, 2021

    @Dreamsorcerer
    SponsorContributorAuthor

    I'm just confused why it worked on beta1...

  5. Dreamsorcerer commented on Mar 14, 2021

    @Dreamsorcerer
    SponsorContributorAuthor

    OK, I see that both asyncpg and psycopg were being installed (which is probably my mistake).

    So, I'm guessing some dependency resolution changed between beta1 and beta3, so it now prefers psycopg even though it can't use it?

  6. CaselIT commented on Mar 14, 2021

    @CaselIT
    Member

    We unfortunately assumed that people would use async drivers with async sqlalchemy, so there was no explicit check. Since that's not the case we added some additional check in beta2 and beta3

    Regarding woking, it does work exactly the same as using time.sleep with asyncio: it will sleep ok but it's not what you usually want to do with asyncio, since it will block the loop while doing so

  7. CaselIT commented on Mar 14, 2021

    @CaselIT
    Member

    OK, I see that both asyncpg and psycopg were being installed (which is probably my mistake).

    So, I'm guessing some dependency resolution changed between beta1 and beta3, so it now prefers psycopg even though it can't use it?

    No change was done. please refer to the documentation on how to specify a dialect: https://docs.sqlalchemy.org/en/14/dialects/postgresql.html#module-sqlalchemy.dialects.postgresql.asyncpg

  8. locked and limited conversation to collaborators on Mar 14, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    asyncioexpected behavior

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions