From: Bernhard H. <bh...@in...> - 2002-01-21 20:27:27
|
"Billy G. Allie" <bg...@mu...> writes: > Bernhard Herzog wrote: > > "Billy G. Allie" <Bil...@mu...> writes: > > > > > Bernhard Herzog wrote: > > > > Is it possible to use pyPgSQL for asynchronous connections? It seems to > > > > be the only Python/PostgreSQL module that actually wraps the relevant > > > > libpg functions, but the Python API doesn't provide access to them. Is > > > > anybody actually using them? > > > > > > The pyPgSQL.PgSQL module does not use asynchronous connections. If you need > > > to use ansynchronous connections you will have to use pyPgSQL.libpq module, > > > which exposes the appropiate API. > > > > That's what I ended up doing. I also modified the copy a bit to > > reactivate the PQconnectStart bindings for asynchronouse connections and > > removed the version specific stuff because that wouldn't work with > > PQconnectStart and we won't need the compatibility code. > > I've re-activated the PQconnectStart bindings in the CVS version. Without the other changes I made it probably doesn't work. > Can you send me the additional things you changed. I am curious as to > what they were. Thanks. A problem with PQconnectStart was that PgConnection_New tried to execute a query (to determine the version of the server) even before the connection procedure had been finished. The query doesn't work at that point and results in a segfault. I don't have to keep backwards compatibility with older PostgreSQL anyway, so I removed all that version code, both in pgconnection and pgresult.c. It might be possible to keep the version code for blocking connections and allow non-blocking connections without the version code by adding a flag in PgConnection_New to make sure that the query is only executed for blocking connections. How large objects (which seems to be the only place where the version information is used) would be supported in compatible way, I don't know and it doesn't look like we'll be needing them. I'll send you a diff with the changes. I should mention, too, that non-blocking support in libpq seems to be more or less broken by design, as another subscriber to this list pointed out to me. Large queries, in this case those where the string passed to PQsendQuery is sufficiently larger than the output buffer of 8K, won't be sent completely and you end up with an error. I'm working on a patch for libpq to make it work. Bernhard -- Intevation GmbH http://intevation.de/ Sketch http://sketch.sourceforge.net/ MapIt! http://mapit.de/ |