On Thu, Nov 3, 2011 at 9:28 PM, leif <not.rea...@online.de> wrote:
> On 4 Nov., 02:15, Tom Boothby <tomas.boot...@gmail.com> wrote:
>> This is fairly easy to do with @parallel:
>>
>> def fast(x):
>>     return x
>>
>> def slow(x):
>>     sleep(x)
>>     return x
>>
>> def slower(x):
>>     sleep(x*x)
>>     return x
>>
>> algorithms = [slower, slow, fast]
>>
>> @parallel(len(algorithms))
>> def fastest(i,x):
>>     global algorithms
>>     return algorithms[i](x)
>>
>> def compute(x):
>>     return fastest([(i,x) for i in range(len(algorithms))]).next()[1]
>
> I doubt that already kills the slow() and slower() processes...
>
>
> -leif

Did you run the example?

sage: compute(50000)
Killing any remaining workers...
50000

-- 
To post to this group, send an email to sage-devel@googlegroups.com
To unsubscribe from this group, send an email to 
sage-devel+unsubscr...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sage-devel
URL: http://www.sagemath.org

Reply via email to