-
Notifications
You must be signed in to change notification settings - Fork 264
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Concurrent read segfault #844
Comments
This scripts gives me Netcdf4 version: 1.4.2
Traceback (most recent call last):
File "segfault.py", line 17, in <module>
with ThreadPool(2) as p:
AttributeError: __exit__ with python 2.7. |
May be related to #640 |
Works with python3.6 if you replace |
You need to use a lock when using netCDF4 with multiple threads. Unfortunately, the underlying HDF5 library is not thread safe. |
Yeah, my rule from experience is that if I'm using multiple threads, all access to netcdf4-python needs to be guarded by a lock. |
You can build HDF5 thread-safe, but it's not the default |
Even if HDF5 is compiled with thread safety, the netcdf4 C library is not thread safe. |
Is that true even for reading/writing independent netCDF3 files?
…On Mon, Sep 3, 2018 at 11:00 PM Ryan May ***@***.***> wrote:
Even if HDF5 is compiled with thread safety, the netcdf4 C library is not
thread safe.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#844 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ABKS1smq67mmjzQVQSAKzwvVu_h-j57kks5uXhbogaJpZM4WXXA1>
.
|
Thanks for the answers. I didn't know the HDF5 library was not thread safe (I must admit I didn't look for this information and took it for granted). @jswhit removing the middle |
There was at least a plan to make the netcdf library thread safe (see https://www.unidata.ucar.edu/blogs/developer/entry/implementing-thread-safe-access-to). @DennisHeimbigner - was that every implemented? |
Not yet. It is waiting on some other library changes. The priority is high, however. |
Hi everyone |
Hi. I had no issues with concurrent reads when using processes so I can't help you. |
Hello
When openning a netcdf file in read mode more than one time in a ThreadPool results in a segfault. When using a process pool there is no issue and the concurrent read works fine. It can be an issue in a web environment where the server is using threads to handle its clients and two or more clients make a request that need to read the same netcdf file.
I have a simple python script and a dataset that reproduces the segfault:
netcdfSegfault.zip
The python script provided in the zip:
Will output the following when executed.
The text was updated successfully, but these errors were encountered: