Dominique wrote:
> On 10 juin, 02:38, Peter Hansen <[EMAIL PROTECTED]> wrote:
>> As Python has no way to actually terminate a thread, can you explain
>> what you mean by "stop this thread"?  Are you simply cloning the code
>> from the wxPython example, with the delayedresult.AbortEvent() object,
>> and calling .set() on it?
> 
> That's exactly what I do.
> My Abort button is linked to an abort function which calls
> abortEvent.set(), like in the demo.
> In the producer function, I launch the query.
> What I'd like to do  is to be able to stop the thread, while the query
> is being done.
> Is it possible or am I trying to do something impossible ?

As no one else has chimed in, I'll go out on a limb a bit and say that 
it's impossible.  Python itself definitely doesn't have any way to 
forcibly kill a thread, at least not one that is buried in an external 
call (e.g. in the sqlite library).

There is a mechanism that's been added in recent versions that can 
terminate (under certain conditions) pure Python code in another thread 
by asynchronously raising an exception: search for "python asynchronous 
exception" and make sure you understand the issues before trying to use it.

If you could restructure your application so the long-running query 
occurs in a separate process, you could "kill" the process using 
operating system support for that, though perhaps not in a clean fashion.

Aside from that, you don't have many options.  What about changing the 
query so that it will return its results in increments, rather than all 
at once?  If it's a long-running query but you can break it up that way, 
then the "check event flag" approach you're using would be able to work.

-Peter

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalchemy@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to