PEP 249 - DB API question

James Mills prologic at shortcircuit.net.au
Tue Nov 4 13:30:32 EST 2008


On Wed, Nov 5, 2008 at 3:52 AM, k3xji <sumerc at gmail.com> wrote:
> As development goes on for a server project, it turns out that I am
> using the MySQLDB and DB interactions excessively. One questions is
> just bothering me, why don't we have a timeout for queries in PEP 249
> (DB API)?

Because not all database engines support this ?

> Is it really safe to wait for a query to finish, means, is it always
> returning, even if the DB server goes down?

Try using the non-blocking features (may be RDBMS specific)

> And, also from my point view, it may be a good feature. We may use
> long/non-critical DB queries with a timeout and slow/critical without
> a timeout. This will give us a little chance to prioritize/consume
> queries on their criticality? And, I don't see so much effort in
> implementing this. One has to change the socket logic in the related
> DB's API source code?

Patches are welcome. A suggestion:

Try spawning a new process to run your query
in. Use the multiprocessing library. Your main
application can then just poll the db/query processes
to see if they're a) finished and b) have a result

Your application server can also c0 kill long running
queries that are "deemed" to be taking "too long"
and may not finish (eg: Cartesian Joins).

--JamesMills

-- 
--
-- "Problems are solved by method"



More information about the Python-list mailing list