Skip to content

Commit 217b537

Browse files
committed
store clib on module level - shared between all instances
1 parent a34b2b4 commit 217b537

File tree

5 files changed

+164
-80
lines changed

5 files changed

+164
-80
lines changed

pygeodiff/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
:license: MIT, see LICENSE for more details.
88
"""
99

10-
from .main import GeoDiff
10+
from .main import GeoDiff, shutdown
11+
1112
from .geodifflib import (
1213
GeoDiffLibError,
1314
GeoDiffLibConflictError,

pygeodiff/geodifflib.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,28 @@
1515
import copy
1616

1717

18+
clib_module = None
19+
20+
21+
def clib():
22+
global clib_module
23+
return clib_module
24+
25+
26+
def init_clib(libname):
27+
global clib_module
28+
if clib_module is None:
29+
clib_module = GeoDiffLib(libname)
30+
return clib_module
31+
32+
33+
def shutdown_clib():
34+
global clib_module
35+
if clib_module is not None:
36+
clib_module.shutdown()
37+
clib_module = None
38+
39+
1840
class GeoDiffLibError(Exception):
1941
pass
2042

0 commit comments

Comments
 (0)