<div dir="ltr"><span style="font-family:arial,sans-serif;font-size:14px">I am not sure which database you're using, but all the mainstream RDBMS is server-client Architecture, when you're running one DML(including the SELECT), the RDBMS setting up a server process, the query running in that process instead of your client process, so I guess your problem can solved in the database layer more elegant than in your program.</span><div style="font-family:arial,sans-serif;font-size:14px">
1. Investigate the reason why you're take more time</div><div style="font-family:arial,sans-serif;font-size:14px">2. Find your DBA or yourself, setting the related parameters in the database.</div><div style="font-family:arial,sans-serif;font-size:14px">
3. If possible, using some embedded language in the database (like PL/SQL in Oracle), it is more convenient.</div><div style="font-family:arial,sans-serif;font-size:14px"><br></div><div style="font-family:arial,sans-serif;font-size:14px">
Regards,</div><div style="font-family:arial,sans-serif;font-size:14px">Jason  </div></div><div class="gmail_extra"><br><br><div class="gmail_quote">2013/1/26 hyperboreean <span dir="ltr"><<a href="mailto:hyperboreean@nerdshack.com" target="_blank">hyperboreean@nerdshack.com</a>></span><br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Here's the use case I want to implement - I have to generate a report<br>
from multiple database servers. This report should be generated every 2<br>
hours. Sometimes it happens that a query on one of the database servers<br>
takes longer than expected and impedes the generation of this report<br>
(that's right, the queries are ran sequential). What I am trying to<br>
achieve is to parallelize the queries on each database server and to be<br>
able to cancel one of them if it takes longer than X minutes.<br>
threading.Thread doesn't support this and seems that in<br>
general programming languages don't implement a way to cancel threads<br>
from the outside.<br>
<br>
Now, I've read all the stackoverflow threads about killing a thread,<br>
canceling a thread after a timeout, but all of them imply that you are<br>
able to check from within the thread if you should end the computation<br>
or not - that's not really my case, where the computation is a SQL<br>
query.<br>
<br>
So, what I have in mind is something like: the main loop starts a<br>
threading.Thread which in turn is responsible for starting another<br>
thread in which the actual computation happens (could be a<br>
threading.Thread or a multiprocessing.Process) *and* checks if the<br>
specified timeout has passed. If the time is up, it exits, letting the<br>
main loop know.<br>
<br>
Lots of words, no code - let me know if you have any suggestions, ideas<br>
to this rant.<br>
<br>
Thanks!<br>
<span class="HOEnZb"><font color="#888888"><br>
<br>
--<br>
<a href="http://mail.python.org/mailman/listinfo/python-list" target="_blank">http://mail.python.org/mailman/listinfo/python-list</a><br>
</font></span></blockquote></div><br><br clear="all"><div><br></div>-- <br>Best wishes,<br><br>Jason Ma<br>
</div>