pyswip icon indicating copy to clipboard operation
pyswip copied to clipboard

Can i have two Prolog instances simultaneously?

Open veryrandomname opened this issue 6 years ago • 6 comments
trafficstars

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.

veryrandomname avatar Nov 13 '19 09:11 veryrandomname

+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

skliarpawlo avatar Mar 03 '20 09:03 skliarpawlo

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).

allComputableThings avatar May 05 '20 07:05 allComputableThings

@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.

skliarpawlo avatar May 05 '20 10:05 skliarpawlo

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 .

allComputableThings avatar May 05 '20 21:05 allComputableThings

https://swi-prolog.discourse.group/t/threaded-queries-rulebase-independence/1236/11

allComputableThings avatar May 05 '20 22:05 allComputableThings

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.

femartip avatar Feb 28 '24 12:02 femartip