[sqlalchemy] Re: Cannot abort wxPython thread with SQLAlchemy

2008-06-12 Thread Dominique

Thanks Peter for your answer.

On 11 juin, 16:16, Peter Hansen [EMAIL PROTECTED] wrote:

 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

That's exactly what I am going to do.

Many thanks for your help

Dominique

--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



[sqlalchemy] Re: Cannot abort wxPython thread with SQLAlchemy

2008-06-11 Thread Peter Hansen

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
-~--~~~~--~~--~--~---



[sqlalchemy] Re: Cannot abort wxPython thread with SQLAlchemy

2008-06-09 Thread Peter Hansen

Dominique wrote:
 I am using delayedresult (which is a class to do threading in
 wxPython) for a query with SQLAlchemy, using SQLite.
 
 I have an 'opened' session in the main App thread.
 
 I create another session under the delayedresult thread.
 When I try to stop this thread with a dedicated button, the thread
 doesn't abort and goes on till it sends the result.

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?

-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
-~--~~~~--~~--~--~---



[sqlalchemy] Re: Cannot abort wxPython thread with SQLAlchemy

2008-06-09 Thread Dominique

Hi Peter,

Thank you very much for answering.

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 ?

Thanks
Dominique
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---