You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Within the Application interface to intercept messages normally printed to standard error.
I am trying to use this, but whenever my Application class implements this method python terminates almost immediately after any calls to control.ground(parts).
For example:
def logger(self, code: clingo.MessageCode, message: str) -> None:
self._data.get_logger().add_log("TEST", message)
def main(self, control: clingo.Control, files: List[str]):
self.__build_program(control)
start_time: float = time.clock()
self._data.get_logger().add_log("ASP_SYSTEM", "Grounder invoked")
if self.is_planning_mode:
control.ground([("base", []), ("planning_module", []), ("recorded_history", [])])
else:
control.ground([("base", []), ("diagnostics_module", []), ("recorded_history", [])])
self._data.get_logger().add_log("ASP_SYSTEM", "Grounder returned (duration {0} seconds)".format(time.clock() - start_time))
start_time = time.clock()
self._data.get_logger().add_log("ASP_SYSTEM", "Solver invoked")
handle: clingo.SolveHandle
with control.solve(on_model = self.on_model, on_finish = self.on_finish, async_ = True) as handle:
while not handle.wait(0.1):
for cursor in '\\|/-':
sys.stdout.write('\r{0}'.format(cursor))
sys.stdout.flush()
self._data.get_logger().add_log("ASP_SYSTEM",
"Solver returned {0} with {1} (duration {2} seconds)".format(handle.get(),
"OPTIMUM FOUND" if handle.get().exhausted else "OPTIMUM NOT FOUND",
time.clock() - start_time))
def __build_program(self, control: clingo.Control) -> None:
builder: clingo.ProgramBuilder
with control.builder() as builder:
part: ast.AST
for part in self.__program:
builder.add(part)
Will print [23:11:31] ASP_SYSTEM: Grounder invoked and then immediately terminate python.
I have tried surrounding the grounder call with a try/except block but this does not work.
I cannot understand the problem at all, it does not seem to throw any sort of error or exception, it just terminates python...
Note that if I comment out the logger method it runs exactly as expected, no errors.
Any ideas?
The text was updated successfully, but these errors were encountered:
Thanks for reporting. The problem is fixed in the wip branch. See the linked commit. The next release will still take a little because there are some further things I want to address.
According to the clingo api documentation 5.4 for python (https://potassco.org/clingo/python-api/5.4/) you can use the method:
def logger(self, code: MessageCode, message: str) -> None:
Within the Application interface to intercept messages normally printed to standard error.
I am trying to use this, but whenever my Application class implements this method python terminates almost immediately after any calls to
control.ground(parts)
.For example:
Will print
[23:11:31] ASP_SYSTEM: Grounder invoked
and then immediately terminate python.I have tried surrounding the grounder call with a try/except block but this does not work.
I cannot understand the problem at all, it does not seem to throw any sort of error or exception, it just terminates python...
Note that if I comment out the logger method it runs exactly as expected, no errors.
Any ideas?
The text was updated successfully, but these errors were encountered: