pyswip
pyswip copied to clipboard
Can i have two Prolog instances simultaneously?
From looking at the code it seems like Prolog is started when the library is imported. Is that necessary? For me this library would only be useful if I could start/stop Prolog processes at will.
+1 also it seems like multiple instances of Prolog share the same prolog state, and I cannot find a way to even reset the state, like cancel all consult calls for example
This is a limitation of SWI prolog. The C interface supported multiple execution threads, but only a single (global) database.
You will not need to start/stop prolog process though (they only run while executing a query).
@stuz5000 thank you! I cannot find a way to change the database either. Do you happen to know if there is any possibility to do revert or replace for consult(...) the same way as it can be done with retract_all(...) for single facts.
Yes. You can place all of your rules and facts into a single module that is independent of the rest of the database. You can them query for and abolish the contents of the module. Modules themselves cannot be cleaned up. There was a recent question about this in the SWI Discourse message group
On Tue, May 5, 2020 at 3:24 AM Pavlo Skliar [email protected] wrote:
@stuz5000 https://github.com/stuz5000 thank you! I cannot find a way to change the database either. Do you happen to know if there is any possibility to do revert or replace for consult(...) the same way as it can be done with retract_all(...) for single facts.
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/yuce/pyswip/issues/74#issuecomment-623974138, or unsubscribe https://github.com/notifications/unsubscribe-auth/AB3QJLCU5PCXQ3W6LYGCTY3RP7SNNANCNFSM4JMW77WQ .
https://swi-prolog.discourse.group/t/threaded-queries-rulebase-independence/1236/11
As this Issue is still not closed. For a solution to this problem I am using pywip_notebook as it creates an instance of Prolog in different modules. I think this may resolve your issues.