CHECK_BLOCKED("solve");
Py_XDECREF(stats);
stats = nullptr;
- static char const *kwlist[] = {"assumptions", "on_model", "on_statistics", "on_finish", "yield_", "async", nullptr};
- Reference pyAss = Py_None, pyM = Py_None, pyS = Py_None, pyF = Py_None, pyYield = Py_False, pyAsync = Py_False;
- ParseTupleAndKeywords(args, kwds, "|OOOOOO", kwlist, pyAss, pyM, pyS, pyF, pyYield, pyAsync);
+ static char const *kwlist[] = {"assumptions", "on_model", "on_statistics", "on_finish", "yield_", "async", "async_", nullptr};
+ Reference pyAss = Py_None, pyM = Py_None, pyS = Py_None, pyF = Py_None, pyYield = Py_False, pyAsync = Py_False, pyAsync_ = Py_False;
+ ParseTupleAndKeywords(args, kwds, "|OOOOOOO", kwlist, pyAss, pyM, pyS, pyF, pyYield, pyAsync, pyAsync_);
std::vector<clingo_literal_t> ass;
if (!pyAss.is_none()) {
clingo_symbolic_atoms_t *atoms;
handle_c_error(clingo_control_symbolic_atoms(ctl, &atoms));
ass = pyToLits(pyAss, atoms, false, false);
}
+ bool async = pyAsync.isTrue() || pyAsync_.isTrue();
clingo_solve_mode_bitset_t mode = 0;
if (pyYield.isTrue()) { mode |= clingo_solve_mode_yield; }
- if (pyAsync.isTrue()) { mode |= clingo_solve_mode_async; }
+ if (async) { mode |= clingo_solve_mode_async; }
auto handle = SolveHandle::construct();
auto notify = handle->notify(&SolveHandle::on_event, pyM, pyS, pyF);
doUnblocked([&](){ handle_c_error(clingo_control_solve(ctl, mode, ass.data(), ass.size(), notify, handle.obj, &handle->handle)); });
- if (!pyYield.isTrue() && !pyAsync.isTrue()) { return handle->get(); }
+ if (!pyYield.isTrue() && !async) { return handle->get(); }
else { return handle; }
}
Object cleanup() {
path -- path to program)"},
// solve
{"solve", to_function<&ControlWrap::solve>(), METH_KEYWORDS | METH_VARARGS,
-R"(solve(self, assumptions, on_model, on_finish, yield_, async) -> SolveHandle|SolveResult
+R"(solve(self, assumptions, on_model, on_finish, yield_, async_) -> SolveHandle|SolveResult
Starts a search.
(Default: [])
yield_ -- The resulting SolveHandle is iterable yielding Model objects.
(Default: False)
-async -- The solve call and SolveHandle.resume() are non-blocking.
+async_ -- The solve call and SolveHandle.resume() are non-blocking.
(Default: False)
-If neither yield_ nor async is set, the function returns a SolveResult right
+If neither yield_ nor async_ is set, the function returns a SolveResult right
away.
Note that in gringo or in clingo with lparse or text output enabled this
def main(prg):
prg.add("p", [], "{a;b;c}.")
prg.ground([("base", [])])
- with prg.solve(on_model=on_model, on_finish=on_finish, async=True) as handle:
+ with prg.solve(on_model=on_model, on_finish=on_finish, async_=True) as handle:
while not handle.wait(0):
# do something asynchronously
print(handle.get())