Hello, do you have an idea how to implement a "timeout" for EllipticCurve.rank(only_use_mwrank=True)?
In my application, I have an array of more than 100 elliptic curves and I want to find a subset of 12 curves with rank 0, if possible, in reasonable time. If not possible in reasonable time, I want my function to throw an exception. But it should terminate after let's say 60 seconds.
For most of my elliptic curves the call r = E.rank(only_use_mwrank=True) terminates after short time (less than 2 seconds, with a result or with an exception). But for some elliptic curves the call E.rank() takes more than 1 hour ...
So, my idea is: I would like to call E.rank(only_use_mwrank=True) in a separate thread - and to terminate the call / the thread after - let's say - 5 seconds.
I tried to find solutions in the internet - but it seems it is very complex because (a) it is not easy to do it in python, (b) it is even more complex to do it with a library call that is in cpython (like E.rank seems to be).
Is there any way how I could do this in sage / python / cypthon?
Thanks a lot Daniel Lauer
Example:
# In this example, myProc2 does not return for 1 hour ... and therefore "blocks" myProc3.
# You may run the example in SageMathCell (http://sagecell.sagemath.org).
def myProc1():
print("starting myProc1")
E = EllipticCurve([0, 146, 0, 1556, 0])
r = E.rank(only_use_mwrank=True)
print("rank = {}".format(r))
print("finished myProc1")
def myProc2():
print("starting myProc2")
E = EllipticCurve([0, - 249730248677555343372, 0, 158929357618867398869672381174059102500, 0])
E.rank(only_use_mwrank=True)
r = E.rank(only_use_mwrank=True)
print("rank = {}".format(r))
print("finished myProc2")
def myProc3():
print("starting myProc3")
E = EllipticCurve([0, 643, 0, -264, 0])
E.rank(only_use_mwrank=True)
r = E.rank(only_use_mwrank=True)
print("rank = {}".format(r))
print("finished myProc3")
myProc1()
myProc2()
myProc3()