[h5py] 421/455: Yet another fix for multithreaded exceptions
Ghislain Vaillant
ghisvail-guest at moszumanska.debian.org
Thu Jul 2 18:19:57 UTC 2015
This is an automated email from the git hooks/post-receive script.
ghisvail-guest pushed a commit to annotated tag 1.3.0
in repository h5py.
commit 20cbbff605001ece28de2ed13fee72c37a4f4a96
Author: andrewcollette <andrew.collette at gmail.com>
Date: Sun Feb 21 22:13:56 2010 +0000
Yet another fix for multithreaded exceptions
---
h5py/h5e.pxd | 2 ++
h5py/h5e.pyx | 51 ++++++++++++++++++++++++---------------------------
2 files changed, 26 insertions(+), 27 deletions(-)
diff --git a/h5py/h5e.pxd b/h5py/h5e.pxd
index 58ed868..35c6686 100644
--- a/h5py/h5e.pxd
+++ b/h5py/h5e.pxd
@@ -230,6 +230,8 @@ cdef extern from "hdf5.h":
herr_t H5Eset_auto(H5E_auto_t func, void *client_data)
herr_t H5Eget_auto(H5E_auto_t *func, void** client_data)
+ herr_t H5Eprint(void *stream)
+
ctypedef herr_t (*H5E_walk_t)(int n, H5E_error_t *err_desc, void* client_data)
herr_t H5Ewalk(H5E_direction_t direction, H5E_walk_t func, void* client_data)
diff --git a/h5py/h5e.pyx b/h5py/h5e.pyx
index 2121e9c..982504f 100644
--- a/h5py/h5e.pyx
+++ b/h5py/h5e.pyx
@@ -381,13 +381,35 @@ cdef herr_t err_callback(void* client_data) with gil:
cpdef int register_thread() except -1:
""" ()
- Register the current thread for native HDF5 exception support. This is
- automatically called by h5py on startup. Safe to call more than once.
+ Register the current thread for native HDF5 exception support.
+
+ Code which uses the low-level HDF5 API (h5py.h5*) is required to call
+ this function before using HDF5. The main thread is automatically
+ registered when h5py is imported. The high-level interface (h5py.*)
+ is unaffected.
+
+ Safe to call more than once.
"""
if H5Eset_auto(err_callback, NULL) < 0:
raise RuntimeError("Failed to register HDF5 exception callback")
return 0
+cpdef int unregister_thread() except -1:
+ """ ()
+
+ Unregister the current thread, turning off HDF5 exception support.
+
+ Restore the default HDF5 error handler, disabling h5py in the current
+ thread. Third-party libraries in this thread are then free to interact
+ with the HDF5 error subsystem as they wish. Call register_thread()
+ again to re-enable exception support.
+
+ Does not affect any other thread. Safe to call more than once.
+ """
+ if H5Eset_auto(H5Eprint, NULL) < 0:
+ raise RuntimeError("Failed to unregister HDF5 exception callback")
+ return 0
+
cdef err_cookie disable_errors() except *:
# Temporarily disable errors for the current thread
cdef err_cookie cookie
@@ -402,30 +424,5 @@ cdef void enable_errors(err_cookie cookie) except *:
if(retval < 0):
raise RuntimeError("Cant' re-enable exception support")
-cdef int capture_count
-cdef H5E_auto_t backup_func
-cdef void* backup_data
-
-cpdef int capture_errors() except -1:
- global backup_func, backup_data, capture_count
- if capture_count != 0:
- capture_count += 1
- return 0
- if(H5Eget_auto(&backup_func, &backup_data)<0):
- raise RuntimeError("Can't back up exception information")
- if(H5Eset_auto(err_callback, NULL)<0):
- raise RuntimeError("Can't install exception handler")
- return 0
-
-cpdef int release_errors() except -1:
- global backup_func, backup_data, capture_count
- if capture_count == 0:
- raise RuntimeError("Illegal call to release_errors")
- capture_count -= 1
- if capture_count == 0:
- if(H5Eset_auto(backup_func, backup_data)<0):
- raise RuntimeError("Can't re-install previous error handler")
- return 0
-
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/h5py.git
More information about the debian-science-commits
mailing list