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.
MIT License
464 stars 97 forks source link

pyswip cannot work with flask #140

Open gamblerltl opened 2 years ago

gamblerltl commented 2 years ago

when i use pyswip in flask func like this: @app.route("...") def lala(): p = Prolog() p.consult('somepath') it will raise : OSError: exception: access violation reading 0x0000000000000050 it seems like pyswip cannot work well with asyn so i try to use a lock but this problem still exist when i used a lock
:(

allComputableThings commented 2 years ago

See: https://github.com/yuce/pyswip/issues/74

1) your code is not async (it would probably work if it were) https://flask.palletsprojects.com/en/2.0.x/async-await/

2) If you plan to multi-thread, at a minimum you'll need one prolog engine per thread. Prolog() does not create a new engine per thread.

See: https://github.com/yuce/pyswip/issues/74

On Thu, Jan 20, 2022 at 3:00 AM gamblerltl @.***> wrote:

when i use pyswip in flask func like this: @app.route("...") def lala(): p = Prolog() p.consult('somepath') it will raise : OSError: exception: access violation reading 0x0000000000000050 it seems like pyswip cannot work well with asyn so i try to use a lock but this problem still exist when i used a lock :(

— Reply to this email directly, view it on GitHub https://github.com/yuce/pyswip/issues/140, or unsubscribe https://github.com/notifications/unsubscribe-auth/AB3QJLHQPJCXWI6XBGRHPK3UW7TLFANCNFSM5MMNMAKQ . You are receiving this because you are subscribed to this thread.Message ID: @.***>