From: poulpe Date: Thu, 17 Mar 2022 13:18:46 +0000 (+0100) Subject: doc: give more context to disconnection detection recipe X-Git-Tag: 3.1~170 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=fd5110c05ff6cc667a0d8defeb537f8b003ed77a;p=thirdparty%2Fpsycopg.git doc: give more context to disconnection detection recipe --- diff --git a/docs/advanced/async.rst b/docs/advanced/async.rst index a89273d6e..7269bd73a 100644 --- a/docs/advanced/async.rst +++ b/docs/advanced/async.rst @@ -272,11 +272,11 @@ out of fashion. Besides, it is inefficient (unless what you really want is a client-server generator of ones), it generates useless traffic and will only detect a disconnection with an average delay of half the polling time. -A more efficient and timely way to detect a server disconnection is to get a -notification from the OS that the connection has something to say: only then -you can test the connection. You can dedicate a thread (or an asyncio task) to -wait on a connection: such thread will perform no activity until awaken by the -OS. +A more efficient and timely way to detect a server disconnection is to create +an additional connection and wait for a notification from the OS that this +connection has something to say: only then you can run some checks. You +can dedicate a thread (or an asyncio task) to wait on this connection: such +thread will perform no activity until awaken by the OS. In a normal (non asyncio) program you can use the `selectors` module. Because the `!Connection` implements a `~Connection.fileno()` method you can just