Skip to content

Commit 52c74ef

Browse files
committed
feat(py-libzfs): drop lock from context manager
truenas/py-libzfs#250
1 parent 3a06d6d commit 52c74ef

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
diff --git libzfs.pyx libzfs.pyx
2+
index 6f9ac94..0b305df 100644
3+
--- libzfs.pyx
4+
+++ libzfs.pyx
5+
@@ -21,7 +21,6 @@ from libc.stdlib cimport realloc
6+
import errno as py_errno
7+
import urllib.parse
8+
9+
-GLOBAL_CONTEXT_LOCK = threading.Lock()
10+
logger = logging.getLogger(__name__)
11+
12+
13+
@@ -519,24 +518,14 @@ cdef class ZFS(object):
14+
self.proptypes[t] = proptypes
15+
16+
def __enter__(self):
17+
- GLOBAL_CONTEXT_LOCK.acquire()
18+
return self
19+
20+
def __exit__(self, exc_type, value, traceback):
21+
- self.__libzfs_fini()
22+
- GLOBAL_CONTEXT_LOCK.release()
23+
- if exc_type is not None:
24+
- raise
25+
-
26+
- def __libzfs_fini(self):
27+
- if self.handle:
28+
- with nogil:
29+
- libzfs.libzfs_fini(self.handle)
30+
-
31+
- self.handle = NULL
32+
+ pass
33+
34+
def __dealloc__(self):
35+
- ZFS.__libzfs_fini(self)
36+
+ with nogil:
37+
+ libzfs.libzfs_fini(self.handle)
38+
39+
def asdict(self):
40+
return [p.asdict() for p in self.pools]

0 commit comments

Comments
 (0)