Canceling an asynchronous solve operation does not always work.
rkaminsk opened this issue · comments
I have been experimenting with the following program:
#script (python)
import clingo
def main(prg):
prg.ground([("pigeon", [])])
for i in range(0,2):
prg.assign_external(clingo.Function("p"), True)
prg.solve()
prg.assign_external(clingo.Function("p"), False)
with prg.solve(async=True) as handle:
#print "wait"
#handle.wait(0.01)
print "cancel"
handle.cancel()
#end.
#const n = 190.
#program pigeon.
#external p.
1 { p(X); q(X) } 1 :- X = 1..n, not p.
:- not n+1 { p(1..n); q(1..n) }, not p.
As long as there is a small wait before an asynchronous solve operation is canceled things work fine. But when the search operation is canceled immediately, the above program consistently hangs. (The program will not be solved in the lifetime of our solar system.) The python wait
and cancel
calls directly map to clasp API calls in ClaspFacade::SolveHandle
.
Thanks. Should be fixed.