Re: Interrput a thread

2011-01-05 Thread Adam Skutt
On Jan 4, 10:53 pm, John Nagle wrote: >      There are systems where there's support designed in for thread > abort.  LISP/Scheme systems tend to support it.  QNX, the real-time > OS, has well worked out thread-abort semantics at the C level. > (QNX has really good features for "not getting stuck"

Re: Interrput a thread

2011-01-04 Thread John Nagle
On 1/4/2011 6:11 PM, Adam Skutt wrote: On Jan 4, 10:12 am, Fuzzyman wrote: This is a case that .NET (C#) handles better than Python or Java. Nope, read the documentation for Thread.Abort() carefully. Thread.Abort() can cause termination inside a static constructor, which is very bad. You s

Re: Interrput a thread

2011-01-04 Thread Adam Skutt
On Jan 4, 10:12 am, Fuzzyman wrote: > > This is a case that .NET (C#) handles better than Python or Java. > Nope, read the documentation for Thread.Abort() carefully. Thread.Abort() can cause termination inside a static constructor, which is very bad. You sure your application can cope with that

Re: Interrput a thread

2011-01-04 Thread Jean-Paul Calderone
On Jan 4, 12:31 pm, Fuzzyman wrote: > On Jan 4, 3:31 pm, Roy Smith wrote: > > > > > In article > > <2ebc11a5-1b45-4faa-97b9-c84f0db01...@k22g2000yqh.googlegroups.com>, > > >  Fuzzyman wrote: > > > It is unsafe to terminate an os level thread at an arbitrary point > > > because it may be executin

Re: Interrput a thread

2011-01-04 Thread Fuzzyman
On Jan 4, 3:31 pm, Roy Smith wrote: > In article > <2ebc11a5-1b45-4faa-97b9-c84f0db01...@k22g2000yqh.googlegroups.com>, > >  Fuzzyman wrote: > > It is unsafe to terminate an os level thread at an arbitrary point > > because it may be executing code in a critical section. > > [...] > > The standar

Re: Interrput a thread

2011-01-04 Thread Roy Smith
In article <2ebc11a5-1b45-4faa-97b9-c84f0db01...@k22g2000yqh.googlegroups.com>, Fuzzyman wrote: > It is unsafe to terminate an os level thread at an arbitrary point > because it may be executing code in a critical section. > [...] > The standard advice is to use a flag and do manual checking t

Re: Interrput a thread

2011-01-04 Thread Fuzzyman
On Jan 4, 3:12 pm, Fuzzyman wrote: > On Dec 29 2010, 11:31 pm, gervaz wrote: > > > Hi all, I need to stop a threaded (using CTR+C or kill) application if > > it runs too much or if I decide to resume the work later. > > I come up with the following test implementation but I wanted some > > sugges

Re: Interrput a thread

2011-01-04 Thread Fuzzyman
On Dec 29 2010, 11:31 pm, gervaz wrote: > Hi all, I need to stop a threaded (using CTR+C or kill) application if > it runs too much or if I decide to resume the work later. > I come up with the following test implementation but I wanted some > suggestion from you on how I can implement what I need

Re: Interrput a thread

2011-01-04 Thread gervaz
On 4 Gen, 07:13, Jean-Paul Calderone wrote: > On Jan 3, 6:17 pm, Adam Skutt wrote: > > > On Jan 3, 5:24 pm, Jean-Paul Calderone > > wrote: > > > > Of course.  The whole point here is not about threads vs processes. > > > It's about shared memory concurrency vs non-shared memory > > > concurrency

Re: Interrput a thread

2011-01-03 Thread Jean-Paul Calderone
On Jan 3, 6:17 pm, Adam Skutt wrote: > On Jan 3, 5:24 pm, Jean-Paul Calderone > wrote: > > > Of course.  The whole point here is not about threads vs processes. > > It's about shared memory concurrency vs non-shared memory > > concurrency.  You can implement both with threads and both with > > pr

Re: Interrput a thread

2011-01-03 Thread Adam Skutt
On Jan 3, 5:24 pm, Jean-Paul Calderone wrote: > Of course.  The whole point here is not about threads vs processes. > It's about shared memory concurrency vs non-shared memory > concurrency.  You can implement both with threads and both with > processes, but threads are geared towards shared memor

Re: Interrput a thread

2011-01-03 Thread Adam Skutt
On Jan 3, 5:05 pm, gervaz wrote: > Regarding the case pointed out by Adam I think the best way to > deal with it is to create a critical section so that the shared memory > will be updated in an atomic fashion. Ok, so if the OS kills the process between taking the lock and releasing it, what are

Re: Interrput a thread

2011-01-03 Thread Diez B. Roggisch
gervaz writes: > On 3 Gen, 22:17, Adam Skutt wrote: >> On Jan 3, 4:06 pm, Jean-Paul Calderone >> wrote: >> >> >> >> > > Multiple processes, ok, but then regarding processes' interruption >> > > there will be the same problems pointed out by using threads? >> >> > No.  Processes can be terminate

Re: Interrput a thread

2011-01-03 Thread Jean-Paul Calderone
On Jan 3, 4:17 pm, Adam Skutt wrote: > On Jan 3, 4:06 pm, Jean-Paul Calderone > wrote: > > > > > > Multiple processes, ok, but then regarding processes' interruption > > > there will be the same problems pointed out by using threads? > > > No.  Processes can be terminated easily on all major plat

Re: Interrput a thread

2011-01-03 Thread gervaz
On 3 Gen, 22:17, Adam Skutt wrote: > On Jan 3, 4:06 pm, Jean-Paul Calderone > wrote: > > > > > > Multiple processes, ok, but then regarding processes' interruption > > > there will be the same problems pointed out by using threads? > > > No.  Processes can be terminated easily on all major platfo

Re: Interrput a thread

2011-01-03 Thread Adam Skutt
On Jan 3, 4:06 pm, Jean-Paul Calderone wrote: > > > Multiple processes, ok, but then regarding processes' interruption > > there will be the same problems pointed out by using threads? > > No.  Processes can be terminated easily on all major platforms.  See > `os.kill`. > Yes, but that's not the

Re: Interrput a thread

2011-01-03 Thread Jean-Paul Calderone
On Jan 3, 3:22 pm, gervaz wrote: > On 3 Gen, 17:47, de...@web.de (Diez B. Roggisch) wrote: > > > > > gervaz writes: > > > On 31 Dic 2010, 23:25, Alice Bevan–McGregor > > > wrote: > > >> On 2010-12-31 10:28:26 -0800, John Nagle said: > > > >> > Even worse, sending control-C to a multi-thread prog

Re: Interrput a thread

2011-01-03 Thread gervaz
On 3 Gen, 17:47, de...@web.de (Diez B. Roggisch) wrote: > gervaz writes: > > On 31 Dic 2010, 23:25, Alice Bevan–McGregor > > wrote: > >> On 2010-12-31 10:28:26 -0800, John Nagle said: > > >> > Even worse, sending control-C to a multi-thread program > >> > is unreliable in CPython.  See "http://bl

Re: Interrput a thread

2011-01-03 Thread Diez B. Roggisch
gervaz writes: > On 31 Dic 2010, 23:25, Alice Bevan–McGregor > wrote: >> On 2010-12-31 10:28:26 -0800, John Nagle said: >> >> > Even worse, sending control-C to a multi-thread program >> > is unreliable in CPython.  See "http://blip.tv/file/2232410"; >> > for why.  It's painful. >> >> AFIK, that

Re: Interrput a thread

2011-01-02 Thread Tim Roberts
gervaz wrote: > >Ok, but then suppose I have multiple long running threads that I want >to delete/suspend because they are tooking too much time, which >solution do you propose? The right solution is to write your threads so they have an escape hatch -- to periodically check a "should I die?" fla

Re: Interrput a thread

2011-01-02 Thread gervaz
On 31 Dic 2010, 23:25, Alice Bevan–McGregor wrote: > On 2010-12-31 10:28:26 -0800, John Nagle said: > > > Even worse, sending control-C to a multi-thread program > > is unreliable in CPython.  See "http://blip.tv/file/2232410"; > > for why.  It's painful. > > AFIK, that has been resolved in Python

Re: Interrput a thread

2010-12-31 Thread Alice Bevan–McGregor
On 2010-12-31 10:28:26 -0800, John Nagle said: Even worse, sending control-C to a multi-thread program is unreliable in CPython. See "http://blip.tv/file/2232410"; for why. It's painful. AFIK, that has been resolved in Python 3.2 with the introduction of an intelligent thread scheduler as p

Re: Interrput a thread

2010-12-31 Thread John Nagle
On 12/29/2010 3:31 PM, gervaz wrote: Hi all, I need to stop a threaded (using CTR+C or kill) application if it runs too much or if I decide to resume the work later. I come up with the following test implementation but I wanted some suggestion from you on how I can implement what I need in a bett