The Python API calls for an explicit close of the session according to example code I have seen. The docs for Julia seem to indicate there is no close() on a session. Would this be a Python/Julia difference to add to the docs? Is there an implicit close, and can one close an existing session by opening another with the same name?
As of right now, all the stuff for closing a session (and most other closable things) is in the finalizer for the object in question.
When they are garbage collected, they will be closed.
Mostly this means that if that no longer have any references, and the garbage collector is triggered, which normaly automatic but can be done by calling gc()
they will be closed and wrapped up properly.
Details on finalizers when calling gc manually here
One should close the session by making all references to it go out of scope.
This could be done by doing it inside a scoping block.
(Eg all the tests are in let blocks. which are particularly for this)
Or by assigning over the variable holding the session.
This has been argued to be a bad thing, and may be going away soon
Adding a differences from python section to the docs is not something I put as high priority, but if someone made a PR I’ld review it.
I’d be fine with defining Base.close(::Session)
. In both Julia and Python, the Session resources are freed when GC runs on the session object so it’s not usually important to manually invoke, as oxinabox says.