Skip to content
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

Fix OSX write limit as workaround for known Python bug #521

Merged
merged 3 commits into from
Jul 25, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
- Fix bug that caused result of ``set_array_compression`` to be overwritten by
``all_array_compression`` argument to ``write_to``. [#510]

- Add workaround for Python OSX write limit bug
(see https://bugs.python.org/issue24658). [#521]

2.0.1 (2018-05-08)
------------------

Expand Down
6 changes: 5 additions & 1 deletion asdf/generic_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,11 @@ def _array_tofile_simple(fd, write, array):

if sys.platform == 'darwin': # pragma: no cover
def _array_tofile(fd, write, array):
OSX_WRITE_LIMIT = 2 ** 32
# This value is currently set as a workaround for a known bug in Python
# on OSX. Individual writes must be less than 2GB, which necessitates
# the chunk size here if we want it to remain a power of 2.
# See https://bugs.python.org/issue24658.
OSX_WRITE_LIMIT = 2 ** 30
if fd is None or array.nbytes >= OSX_WRITE_LIMIT and array.nbytes % 4096 == 0:
return _array_tofile_chunked(write, array, OSX_WRITE_LIMIT)
return _array_tofile_simple(fd, write, array)
Expand Down