Skip to content

Commit

Permalink
feat(py-libzfs): drop lock from context manager
Browse files Browse the repository at this point in the history
  • Loading branch information
rkojedzinszky committed Nov 6, 2024
1 parent 9198ec0 commit 7fd6e63
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions nas_ports/devel/py-libzfs/files/patch-simple-context-manager
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
diff --git libzfs.pyx libzfs.pyx
index 6f9ac94..0b305df 100644
--- libzfs.pyx
+++ libzfs.pyx
@@ -21,7 +21,6 @@ from libc.stdlib cimport realloc
import errno as py_errno
import urllib.parse

-GLOBAL_CONTEXT_LOCK = threading.Lock()
logger = logging.getLogger(__name__)


@@ -519,24 +518,14 @@ cdef class ZFS(object):
self.proptypes[t] = proptypes

def __enter__(self):
- GLOBAL_CONTEXT_LOCK.acquire()
return self

def __exit__(self, exc_type, value, traceback):
- self.__libzfs_fini()
- GLOBAL_CONTEXT_LOCK.release()
- if exc_type is not None:
- raise
-
- def __libzfs_fini(self):
- if self.handle:
- with nogil:
- libzfs.libzfs_fini(self.handle)
-
- self.handle = NULL
+ pass

def __dealloc__(self):
- ZFS.__libzfs_fini(self)
+ with nogil:
+ libzfs.libzfs_fini(self.handle)

def asdict(self):
return [p.asdict() for p in self.pools]

0 comments on commit 7fd6e63

Please sign in to comment.