Skip to content
Advertisement

Is connect_timeout a valid URL parameter acquiring a connection via Peewee’s playhouse.db_url.connect?

I’m using Peewee as ORM and connect to a Postgres database (psycopg2) using the Playhouse extension db_url.connect. My URL is a vanilla postgresql://username:pass@host:port/dbname?options=... so not using pooling or anything advanced at the moment.

Some times when I call connect it hangs for a long time and doesn’t come back. So I appended to my database URL the parameter &connect_timeout=3 meaning to try for at most 3 seconds and fail-fast with a timeout rather than hanging forever. However, I am not sure whether this argument is supported by Peewee/Playhouse/Psycopg2 … can anyone confirm?

Furthermore, where can I find all the URL parameters supported by Peewee/Playhouse/Psycopg2?

Advertisement

Answer

The psycopg2 doc links in turn to the libpq list of supported parameters:

https://www.postgresql.org/docs/current/libpq-connect.html#LIBPQ-PARAMKEYWORDS

connect_timeout is supported by both peewee and psycopg2:

JavaScript

Peewee passes the parameters, including arbitrary ones like connect_timeout, back to the constructor of the DB-API Connection class.

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement