yuce / pyswip

PySwip is a Python - SWI-Prolog bridge enabling to query SWI-Prolog in your Python programs. It features an (incomplete) SWI-Prolog foreign language interface, a utility class that makes it easy querying with Prolog and also a Pythonic interface.
https://pyswip.org
MIT License
472 stars 97 forks source link

Multithreading in Pyswip #120

Closed ShubhamSharma1808 closed 3 years ago

ShubhamSharma1808 commented 3 years ago

On accessing pyswip in a thread it gives segmentation fault in Linux(Ubuntu) and memory violation in Windows. if there is some way to achieve multithreading in pyswip please help

allComputableThings commented 3 years ago

That's the expected behavior from libswipl. You need to create a new engine for each thread.

On Tue, Mar 30, 2021 at 6:46 AM SHUBHAM SHARMA @.***> wrote:

On accessing pyswip in a thread it gives segmentation fault in Linux(Ubuntu) and memory violation in Windows.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/yuce/pyswip/issues/120, or unsubscribe https://github.com/notifications/unsubscribe-auth/AB3QJLDPTX44POTUK7KXUQ3TGHI2RANCNFSM42CCYLFQ .

ExplosionArt commented 3 years ago

@stuz5000 By new engine, do you mean a new object of the Prolog class? If not, kindly specify what is the context of "engine" here.

allComputableThings commented 3 years ago

It's only a concept in the C API - pyswip has only wrapped a subset of those functions in swipl.

You’d need to identify those APIs and wrap the with ctypes annotations (as pyswip does). You could copy the method pyswip does for the new engine functions (but following the code to where it calls PL_blahblah( ... ) and copy the pattern) and use it in your local code, or someone could submit a PR.

On Tue, Mar 30, 2021 at 6:51 AM Ajitem Joshi @.***> wrote:

@stuz5000 https://github.com/stuz5000 By new engine, do you mean the new object of the Prolog class?

— You are receiving this because you were mentioned.

Reply to this email directly, view it on GitHub https://github.com/yuce/pyswip/issues/120#issuecomment-810268455, or unsubscribe https://github.com/notifications/unsubscribe-auth/AB3QJLB7G3QLEYQBFGOC34DTGHJOZANCNFSM42CCYLFQ .

ShubhamSharma1808 commented 3 years ago

In the open Issue#3, I found the solution. it worked for me. here's the link for that.