Skip to content

TST, BUG: Re-raise MemoryError exception in test_large_zip's process#16890

Merged
seberg merged 3 commits into
numpy:masterfrom
antlarr-suse:master
Jul 18, 2020
Merged

TST, BUG: Re-raise MemoryError exception in test_large_zip's process#16890
seberg merged 3 commits into
numpy:masterfrom
antlarr-suse:master

Conversation

@antlarr-suse
Copy link
Copy Markdown
Contributor

Since #15893, test_large_zip's actual test is run in a child process,
so when this test raises a MemoryError exception, the exception is
lost and the @requires_memory decorator can't catch it to return
an xfail.

This commit uses a boolean variable in shared memory to flag if
the exception was raised, and in that case, re-raise it in the
parent process.

Fixes #16889

Since numpy#15893, test_large_zip's actual test is run in a child process,
so when this test raises a MemoryError exception, the exception is
lost and the @requires_memory decorator can't catch it to return
an xfail.

This commit uses a boolean variable in shared memory to flag if
the exception was raised, and in that case, re-raise it in the
parent process.

Fixes numpy#16889
Copy link
Copy Markdown
Member

@anirudh2290 anirudh2290 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a few nits, overall LGTM ! Thank you for the fix @antlarr-suse !

Comment thread numpy/lib/tests/test_io.py Outdated
def test_large_zip(self):
def check_large_zip():
def check_large_zip(memoryerror_raised):
memoryerror_raised.value=False
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit:

Suggested change
memoryerror_raised.value=False
memoryerror_raised.value = False

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops, of course! I don't know how they slipped by. Fixed.

Comment thread numpy/lib/tests/test_io.py Outdated
try:
np.savez(os.path.join(tmpdir, 'test.npz'), test_data=test_data)
except MemoryError:
memoryerror_raised.value=True
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit:

Suggested change
memoryerror_raised.value=True
memoryerror_raised.value = True

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed too

@seberg
Copy link
Copy Markdown
Member

seberg commented Jul 18, 2020

Thanks! Was just going to merge it, but I think we may want to put the try/except clause to include the array creation, which can error out almost as plausibly?

Move the try...except block out so it also catches the exceptions
raised when allocating test_data, as suggested by @seberg in numpy#16890
@antlarr
Copy link
Copy Markdown

antlarr commented Jul 18, 2020

Thanks! Was just going to merge it, but I think we may want to put the try/except clause to include the array creation, which can error out almost as plausibly?

It never happened here, but indeed, in a system with less than ~2GBs available it can raise that exception too.

I've added that change and adjusted the lines so they are within 80 chars width

@seberg
Copy link
Copy Markdown
Member

seberg commented Jul 18, 2020

Thanks @antlarr will putting it in. Should be reasonable enough for the moment, although I suppose tweaking the decorator or skipping for 32bits could be an option on top of it.

@seberg seberg merged commit 9765987 into numpy:master Jul 18, 2020
charris pushed a commit to charris/numpy that referenced this pull request Jul 19, 2020
…umpygh-16890)

Since numpy#15893, test_large_zip's actual test is run in a child process,
so when this test raises a MemoryError exception, the exception is
lost and the @requires_memory decorator can't catch it to return
an xfail.

This commit uses a boolean variable in shared memory to flag if
the exception was raised, and in that case, re-raise it in the
parent process.

Fixes numpy#16889
@charris charris removed the 09 - Backport-Candidate PRs tagged should be backported label Jul 19, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

test_large_zip fails in i586 after #15893

5 participants