> Date: Fri, 10 Feb 2006 16:44:09 +0100 > From: [EMAIL PROTECTED] > Subject: [PyGreSQL] Aborting cursor.execute statement > ... > Here is my question : I'm writing a multi-threaded server app that uses a > pgdb connection. One thread is in charge of all the communication through > pgdb and the other threads pass it their queries in a queue and wait for > for the result to be available. Some queries might need several minutes > before returning, so I'd like to be able to timeout those quieries so that > they do not block the other threads waiting for data too. > > I've tried to close the cursor and even the connection while the execute > statement is running but it always waits for the cursor.execute() statement > to return before raising an exception. > > Is there a way of aborting the execution of an SQL statement ?
This isn't a threading hack, but in recent versions of postgres you can set the runtime parameter 'statement_timeout', e.g.: set statement_timeout to 5000; to set the statement timeout to 5000 msec. for that connection. Any query taking longer than that gets terminated in an orderly way. -- George Young -- "Are the gods not just?" "Oh no, child. What would become of us if they were?" (CSL) _______________________________________________ PyGreSQL mailing list [email protected] http://mailman.vex.net/mailman/listinfo/pygresql
