Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a method to unload geodiff library from python #205

Open
wonder-sk opened this issue Oct 17, 2023 · 0 comments · May be fixed by #208
Open

Add a method to unload geodiff library from python #205

wonder-sk opened this issue Oct 17, 2023 · 0 comments · May be fixed by #208
Assignees
Labels
enhancement New feature or request pygeodiff

Comments

@wonder-sk
Copy link
Contributor

It would be useful to have a shutdown() function in pygeodiff that would force unload of the loaded dynamic library using ctypes. This would help especially on Windows, where the .pyd file gets write-protected when it gets loaded, and then QGIS plugin manager is unable to upgrade/reinstall Mergin Maps plugin, because it is not possible to delete the .pyd file. Having the shutdown() function would allow us to use it in plugin's unload() handler to remove the write protection lock.

This works fine on Windows to release the lock:

from _ctypes import FreeLibrary
geodiff = pygeodiff.GeoDiff()
FreeLibrary(geodiff.clib.lib._handle)

As a part of this, it would be good to do a bit of code refactor: GeoDiffLib class now handles both library loading and handling of context. We should separate those, because the library can be loaded just once, but there may be multiple contexts (with different logging setups). The library (ctypes.CDLL instance) could be stored at the module level and lazy-loaded.

@wonder-sk wonder-sk added enhancement New feature or request pygeodiff labels Oct 17, 2023
@PeterPetrik PeterPetrik self-assigned this Jan 16, 2024
@PeterPetrik PeterPetrik linked a pull request Jan 16, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request pygeodiff
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants