robocorp / java-access-bridge-wrapper

Python wrapper around the Java Access Bridge Windows .dll
Apache License 2.0
16 stars 6 forks source link

Free the loaded library at shutdown #11

Open mmokko opened 1 year ago

mmokko commented 1 year ago

There has been cases where a python error is raised from the main thread where java-access-bridge-wrapper has been imported. To tackle this it would be safer to manually unload the .dll library to make sure the memory is free and no exceptions from the java application is causing issues in the access bridge user side.

There is unfortunately no direct way to unload or free the loaded .dll library within the same Python process. The library will be unloaded automatically when the Python process terminates.

There is an API in the _ctypes implementation side for freeing a loaded library, but the ctypes library should be considerer as the public API and it doesn't expose it.

I'll leave this PR open if this is needed later to be merged to fix the error cases.