Hi, Well, the function signature in question is (in the referred file h5d.pyx):
"cdef int H5PY_H5Dread(<stuff>) nogil except -1" which compiles just fine... is this going to stop working? Is there a better way to do it? It seems like "except -1" simply translates to "after this function is called, if the return code is -1, a Python exception happened in this thread". It seems like the GIL should be reacquired, the nogil block exited immediately, and the appropriate branches of any try...except...finally statement should be executed. If -1 isn't returned, the GIL isn't touched. Whatever happens, I need to be able to run nogil code (reading in data) which can possibly acquire the GIL and set an exception (via a callback), and then be able to detect and propagate the exception back to Python. I am certainly open to refactoring the code if there's a better way to do this in Cython. Andrew Collette On Tue, Apr 14, 2009 at 12:13 PM, Stefan Behnel <[email protected]> wrote: > Hi, > > just a quick note on this: > > Andrew Collette wrote: >> void HDF5_read_data(...) except -1 >> [...] >> try: >> with nogil: >> HDF5_read_data(...) >> finally: >> ... some cleanup ... >> >> Importantly, if the function HDF5_read_data is declared "except *", >> Cython immediately crashes if an exception is raised > > It shouldn't allow you to do that at all. I assume you declared the > function "nogil" to call it in a "with nogil" block. Combining "nogil" with > exception handling should raise an error at compile time. > > There may be cases where this rule could potentially be relaxed, but the > compiler should catch this early in any case. > > Stefan > > _______________________________________________ > Cython-dev mailing list > [email protected] > http://codespeak.net/mailman/listinfo/cython-dev > > _______________________________________________ Cython-dev mailing list [email protected] http://codespeak.net/mailman/listinfo/cython-dev
