Re: Timed execution in eval

2008-03-09 Thread castironpi
> Write the docs: > > > when two threads simultaneously increment the reference count of the same > > object > > Well, the example sucked.  Just synchronize ref count manipulation. > Every OS has locking primitives, and a library exists to deny requests > to block that lock dead.  How integral is

Re: Timed execution in eval

2008-03-09 Thread castironpi
> >  > and I want to be able to stop [functions] if they run too long. > > > That's tricky [due to a synthetic limitation]. It would suck if you couldn't hold the GIL for as long as you need to. But how much is it used? Wrote the docs: > when two threads simultaneously increment the reference co

Re: Timed execution in eval

2008-03-08 Thread Guilherme Polo
2008/3/7, Steven D'Aprano <[EMAIL PROTECTED]>: > On Fri, 07 Mar 2008 08:12:38 -0800, alex.pedwysocki wrote: > > > I have various bits of code I want to interpret and run at runtime in > > eval ... > > > I hope that code doesn't contain any data coming from an untrusted user. > > > > > I want to

Re: Timed execution in eval

2008-03-08 Thread castironpi
On Mar 7, 9:43 pm, George Sakkis <[EMAIL PROTECTED]> wrote: > On Mar 7, 11:12 am, [EMAIL PROTECTED] wrote: > > > I have various bits of code I want to interpret and run at runtime in > > eval ... > > Check out these two recipes: > > - Using signals:http://aspn.activestate.com/ASPN/Cookbook/Python/R

Re: Timed execution in eval

2008-03-07 Thread George Sakkis
On Mar 7, 11:12 am, [EMAIL PROTECTED] wrote: > I have various bits of code I want to interpret and run at runtime in > eval ... > > I want to be able to detect if they fail with error, I want to be able > to time them, and I want to be able to stop them if they run too > long. I cannot add code to

Re: Timed execution in eval

2008-03-07 Thread castironpi
On Mar 7, 4:07 pm, Steven D'Aprano <[EMAIL PROTECTED] cybersource.com.au> wrote: > > I want to be able to detect if [certain threads] fail with error, > > You can't? Why ever not? Try this. ext can be found in 'C Function in a Python Context' on google groops. import ext extA= ext.Ext() extA[ 'a

Re: Timed execution in eval

2008-03-07 Thread Steven D'Aprano
On Fri, 07 Mar 2008 08:12:38 -0800, alex.pedwysocki wrote: > I have various bits of code I want to interpret and run at runtime in > eval ... I hope that code doesn't contain any data coming from an untrusted user. > I want to be able to detect if they fail with error, That's what try...except

Re: Timed execution in eval

2008-03-07 Thread castironpi
On Mar 7, 10:12 am, [EMAIL PROTECTED] wrote: > I have various bits of code I want to interpret and run at runtime in > eval ... import sys from time import clock, sleep from threading import Timer TimeoutError= type('TimeoutError',(Exception,),{}) class Elapse: def __init__( self ): s

Re: Timed execution in eval

2008-03-07 Thread castironpi
On Mar 7, 10:12 am, [EMAIL PROTECTED] wrote: > I have various bits of code I want to interpret and run at runtime in > eval ... > > I want to be able to detect if they fail with error, I want to be able > to time them, and I want to be able to stop them if they run too > long.  I cannot add code to

Timed execution in eval

2008-03-07 Thread alex . pedwysocki
I have various bits of code I want to interpret and run at runtime in eval ... I want to be able to detect if they fail with error, I want to be able to time them, and I want to be able to stop them if they run too long. I cannot add code to the eval'd strings that will help me accomplish this.