I am developing a project using Prolog as back-end and python as front-end. Python is calling a prolog file using the call command.
The concept I am using in prolog is that on first time calling prolog file from python, the prolog file does some processing and save the values in the assert and continues to do this for a long time. Meanwhile, another call from python to the same prolog file picks items from the assert and do some processing on it.
The problem I think is that for the second call to prolog file, the assert from the first file is not available. Basically, each time new asserts are created for the same file.
One solution, I can think is that instead of using asserts, I can use some external database such as file which can be accessed by any process. The problem with this would be to manage locking on the file by the two processes. So this shows me that I should go for any stable database such as mysql which can handle this problem automatically.
Example
First time calling from python swipl -g func1 file1 % Saves item in asserts
Second time calling swipl -g func2 file1 % Picks items from asserts and do some processing
Output The assert in the second call is empty but shows assert values in the first file.
Is there any way of avoinding these external databases?
I got one solution which is given here
Issues with storage of facts in Prolog
I will be trying this.