Thanks Nils.  (In case you were wondering, I am using pari/gp to compute
spaces of modular forms).  I'll do some experiments: I have examples where
one method takes 10s of hours while another only a few minutes, but other
examples where it is the other way round!  and I have not yet been able to
work out what makes the difference.

John

On Thu, 25 Oct 2018 at 19:15, Nils Bruin <nbr...@sfu.ca> wrote:

> On Thursday, October 25, 2018 at 9:12:56 AM UTC-7, Nils Bruin wrote:
>>
>> On Thursday, October 25, 2018 at 7:13:26 AM UTC-7, John Cremona wrote:
>>>
>>> sage: for res in apply([f,g]): print res; break
>>> (((<function f at 0x7fb0537d6050>,), {}), 3^2 * 12248508919 *
>>> 263416276811813669131602539468011)
>>>
>>> The first bit of the output shows that it is f which returns the
>>> result.  But I don't know if g stops working because of the 'break' -- does
>>> it?
>>>
>>> It probably does, but you might program it a little more explicitly.
>
> If you change one of the functions to
>
> def g(N):
>     while True:
>         continue
>     return 0
>
> and do something like
>
> @parallel(ncpus=4)
> def apply(func):
>     return func(29038109543453453498320938204932840238210981)
>
> you have a little better guarantee that there will be a dangling job, so
> you can check with "top" if termination happens.
>
> With
>
> A=apply([f,g])
> res=A.next()
>
> I did see a dangling job. This was killed with
>
> del A
>
> As discussed before, that's not something you can formally rely on in
> python.
>
> As you can see here:
>
>
> https://github.com/sagemath/sage/blob/6187d261eca3c980e575b53d1a31f580ba8cfdfd/src/sage/parallel/use_fork.py#L230
>
> the generator function that produces the results does clean up after
> itself (and indeed, "delete" of a generator function that is in operation
> does trigger the "finally" clauses, as you'd home). It would be much better
> if that clean-up could be triggered explicitly, but that would require
> exposing a little more of the execution state on the "Parallel" object. It
> would be a fairly straightforward and small for someone with good python
> knowledge.
>
> In fact, in Py3, the support for asynchronous operations and coroutines
> has been MUCH improved, so at some point the parallel tools in sage should
> probably be rewritten to cooperate better in that framework.
>
> --
> You received this message because you are subscribed to the Google Groups
> "sage-support" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to sage-support+unsubscr...@googlegroups.com.
> To post to this group, send email to sage-support@googlegroups.com.
> Visit this group at https://groups.google.com/group/sage-support.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To post to this group, send email to sage-support@googlegroups.com.
Visit this group at https://groups.google.com/group/sage-support.
For more options, visit https://groups.google.com/d/optout.

Reply via email to