Re: closing a connection from "outside" an application (for testing)
Manlio Perillo <[email protected]>
| Newsgroups | gmane.comp.python.db.psycopg.devel |
|---|---|
| Message-ID | <[email protected]> |
Federico Di Gregorio ha scritto: > Il giorno gio, 03/01/2008 alle 21.26 -0800, Webb Sprague ha scritto: >> Is there a way for psycopg to return the PID of the process it is >> connected to, primarily for logging (and killing)? I am still trying >> to figure out how to stop a run of my program in mid-stream (besides a >> sleep() or waiting on a signal...), but that will get me started. > > No way, right now (unless you can do that using a query; I don't know.) > The backend id and key are sent by PostgreSQL using the BackendKeyData message, during the startup cycle. libpq has a PQgetCancel function, that returns an opaque PGcancel structure, and the PQcancel function. The backend id is stored in PGconn.be_pid, the key in PGconn.be_pid (but they are private). These values are also stored in the PGcancel structure (and, again, they are private) > [...] Regards Manlio Perillo