Skip to content

Queries are blocking the main loop #1378

Closed
@laggron42

Description

@laggron42

Describe the bug

When running very large queries, I noticed the main loop in my program stopped responding.

I am coding a Discord bot (using discord.py, which is maintaining a gateway connexion), and running large queries result in the gateway being blocked, and the bot stops responding until the query is over.

To Reproduce

  1. Have a large enough table
  2. Create a task using loop.create_task() that only consists of printing on the standard output every second
  3. Query all columns using await TableName.all() in a task or the main loop. This query in my case takes ~120 seconds
  4. See that your messages from the other task stopped being printed during two minutes

Expected behavior

An async library should not block. When waiting for the query, the async task should be freed to let it take care of other jobs. It's literally performing the same as a sync library and creates huge problems in async apps that needs to scale.

Additional context

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