Skip to content

Set command_timeout for all queries #725

@thomas-maschler

Description

@thomas-maschler
  • GINO version: 1.0.1
  • Python version: 3.8
  • asyncpg version: 0.21.0
  • aiocontextvars version:
  • PostgreSQL version: 11.6

Description

I'd like to set a maximum execution time for queries and cancel all queries server-side if limit is exceeded. Similar to the SET statement_timeout = 10000; in PostgreSQL.

Asyncpg has the connection parameter command_timeout, which seems to to the same thing. How can I make use of it in Gino with FastAPI?

What I Did

app = FastAPI(title="My App")

db = Gino(
    app,
    host=DATABASE_CONFIG.host,
    port=DATABASE_CONFIG.port,
    user=DATABASE_CONFIG.username,
    password=DATABASE_CONFIG.password,
    database=DATABASE_CONFIG.database,
    pool_min_size=5,
    pool_max_size=10,
    command_timeout=10000
)

This doesn't work.

How else can I set this option?

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionA community question, closed when inactive.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions