Skip to content

Connection.reset fails on Amazon Redshift#29

@emirot

Description

@emirot

Let's say I have two long running queries that I'd like to run concurrently
Here is my questions :

  • Does asyncpg will help in that case ?
  • using concurrent.futures will do the same ?
importasyncioimportasyncpgasyncdefconnect_to_db(): pool=awaitasyncpg.create_pool("postgres://user:pass@localhost:5555/dev", command_timeout=60) conn1=awaitpool.acquire() conn2=awaitpool.acquire() returnpool, conn1, conn2asyncdefcreate_table_a(conn): awaitconn.execute('CREATE TABLE my_schema.mytab_a (a int)') asyncdefcreate_table_b(conn): awaitconn.execute('CREATE TABLE my_schema.mytab_b (b int)') loop=asyncio.get_event_loop() pool, conn1, conn2=loop.run_until_complete(connect_to_db()) tasks= [asyncio.ensure_future(create_table_a(conn1)), asyncio.ensure_future(create_table_b(conn2))] loop.run_until_complete(asyncio.wait(tasks)) #release the pool and the connections

Thanks for this library

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