-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
CI/TST: Error on PytestUnraisableExceptionWarning instead of using psutil to check open resources #51443
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
Conversation
…for open resouces for tests
there have been times in the past where we did leave files open incorrectly, which I think the check this removes would catch. does the check this adds still catch those? |
Correct for example
|
awesome, thanks for explaining |
Looks like this caught actual issues with open files in |
# https://github.com/dateutil/dateutil/issues/197 | ||
pytest.skip( | ||
"tzlocal() on a 32 bit platform causes internal overflow errors" | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
are we giving incorrect results in these cases?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Running the 32 bit container locally it appears this still returns the correct result but hits the traceback in the dateutil issue
>>> from pandas import Timestamp
>>> import dateutil.tz
>>> dt = Timestamp("2100-01-01 00:00:00", tz=dateutil.tz.tzlocal())
Traceback (most recent call last):
File "pandas/_libs/tslibs/tzconversion.pyx", line 125, in pandas._libs.tslibs.tzconversion.Localizer.utc_val_to_local_val
return utc_val + _tz_localize_using_tzinfo_api(
File "pandas/_libs/tslibs/tzconversion.pyx", line 736, in pandas._libs.tslibs.tzconversion._tz_localize_using_tzinfo_api
dt = _astimezone(dts, tz)
File "pandas/_libs/tslibs/tzconversion.pyx", line 768, in pandas._libs.tslibs.tzconversion._astimezone
return tz.fromutc(result)
File "/root/virtualenvs/pandas-dev/lib/python3.8/site-packages/dateutil/tz/_common.py", line 144, in fromutc
return f(self, dt)
File "/root/virtualenvs/pandas-dev/lib/python3.8/site-packages/dateutil/tz/_common.py", line 261, in fromutc
_fold = self._fold_status(dt, dt_wall)
File "/root/virtualenvs/pandas-dev/lib/python3.8/site-packages/dateutil/tz/_common.py", line 196, in _fold_status
if self.is_ambiguous(dt_wall):
File "/root/virtualenvs/pandas-dev/lib/python3.8/site-packages/dateutil/tz/tz.py", line 254, in is_ambiguous
naive_dst = self._naive_is_dst(dt)
File "/root/virtualenvs/pandas-dev/lib/python3.8/site-packages/dateutil/tz/tz.py", line 260, in _naive_is_dst
return time.localtime(timestamp + time.timezone).tm_isdst
OverflowError: timestamp out of range for platform time_t
Exception ignored in: 'pandas._libs.tslibs.conversion._localize_tso'
Traceback (most recent call last):
File "pandas/_libs/tslibs/tzconversion.pyx", line 125, in pandas._libs.tslibs.tzconversion.Localizer.utc_val_to_local_val
return utc_val + _tz_localize_using_tzinfo_api(
File "pandas/_libs/tslibs/tzconversion.pyx", line 736, in pandas._libs.tslibs.tzconversion._tz_localize_using_tzinfo_api
dt = _astimezone(dts, tz)
File "pandas/_libs/tslibs/tzconversion.pyx", line 768, in pandas._libs.tslibs.tzconversion._astimezone
return tz.fromutc(result)
File "/root/virtualenvs/pandas-dev/lib/python3.8/site-packages/dateutil/tz/_common.py", line 144, in fromutc
return f(self, dt)
File "/root/virtualenvs/pandas-dev/lib/python3.8/site-packages/dateutil/tz/_common.py", line 261, in fromutc
_fold = self._fold_status(dt, dt_wall)
File "/root/virtualenvs/pandas-dev/lib/python3.8/site-packages/dateutil/tz/_common.py", line 196, in _fold_status
if self.is_ambiguous(dt_wall):
File "/root/virtualenvs/pandas-dev/lib/python3.8/site-packages/dateutil/tz/tz.py", line 254, in is_ambiguous
naive_dst = self._naive_is_dst(dt)
File "/root/virtualenvs/pandas-dev/lib/python3.8/site-packages/dateutil/tz/tz.py", line 260, in _naive_is_dst
return time.localtime(timestamp + time.timezone).tm_isdst
OverflowError: timestamp out of range for platform time_t
>>> dt.is_leap_year
False
proc = psutil.Process() | ||
flist = proc.open_files() | ||
yield | ||
flist2 = proc.open_files() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
documenting in case we wind up keeping this: looks like all of the flaky failures have raddr.port of either 5432 or 3306 (mostly 5432), which correspond to postgres and mysql defaults, respectively. We could filter those out here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FWIW I have seen the port 443 show up a few times too
merging, I guess we should backport to get rid of these on the 2.0.x branch? |
thx @mroeschke |
…ionWarning instead of using psutil to check open resources
nice! |
…ExceptionWarning instead of using psutil to check open resources) (#51507) Backport PR #51443: CI/TST: Error on PytestUnraisableExceptionWarning instead of using psutil to check open resources Co-authored-by: Matthew Roeschke <[email protected]> Co-authored-by: Patrick Hoefler <[email protected]>
Using
psutil
to check for open resources in tests has been a false positive for a while, picking up unrelated connections such as the database services.Erroring on
ResourceWarnings
, captured byPytestUnraisableExceptionWarning
, should be sufficient for validating that resources are not left open as a result of a test. pytest-dev/pytest#9825