Memory problem while using the Janus library to call Prolog from Python

I wonder if the __del__ method is being called implicitly in call cases?

I can provide a patch that adds a context manager, which ought to rule that out. (I haven’t submitted the PR because I’ve encountered something strange with exception handling, which I want to fix first (and I also did a bit of refactoring); however, if it’s important, I could probably quickly make a PR).

My work-in-progress (with some text cases that show how to use it): WIP context manager for swipy · GitHub
For more on how to use context managers: Problem with Calling Prolog from Python - #5 by peter.ludemann