Commit 27667b64 authored by Jason Madden's avatar Jason Madden

More PyPy tweaks.

parent 07891830
......@@ -108,20 +108,24 @@ else:
(socket.listen(1)). Unlike the lsof implementation, this will only
return sockets in a state like that.
"""
if sysinfo.PYPY:
# We've seen OSError: No such file or directory /proc/PID/fd/NUM.
# This occurs in the loop that checks open files. It first does listdir()
# and then tries readlink() on each file. But the file went away.
# This must be because of async GC in PyPy running destructors at arbitrary
# times. This became an issue in PyPy 7.2. Try to clean that up before we
# begin.
import gc
gc.collect()
gc.collect()
# We've seen OSError: No such file or directory
# /proc/PID/fd/NUM. This occurs in the loop that checks open
# files. It first does listdir() and then tries readlink() on
# each file. But the file went away. This must be because of
# async GC in PyPy running destructors at arbitrary times.
# This became an issue in PyPy 7.2 but could theoretically be
# an issue with any objects caught in a cycle. Try to clean
# that up before we begin.
import gc
gc.collect()
gc.collect()
results = dict()
process = psutil.Process()
results['data'] = process.open_files() + process.connections('all')
gc.disable()
try:
process = psutil.Process()
results['data'] = process.open_files() + process.connections('all')
finally:
gc.enable()
for x in results['data']:
results[x.fd] = x
results['data'] += ['From psutil', process]
......
......@@ -110,12 +110,17 @@ class Test(greentest.TestCase):
def make_open_socket(self):
s = socket.socket()
s.bind(DEFAULT_BIND_ADDR_TUPLE)
if WIN or greentest.LINUX:
# Windows and linux (with psutil) doesn't show as open until
# we call listen (linux with lsof accepts either)
s.listen(1)
self.assert_open(s, s.fileno())
try:
s.bind(DEFAULT_BIND_ADDR_TUPLE)
if WIN or greentest.LINUX:
# Windows and linux (with psutil) doesn't show as open until
# we call listen (linux with lsof accepts either)
s.listen(1)
self.assert_open(s, s.fileno())
except:
s.close()
s = None
raise
return s
# Sometimes its this one, sometimes it's test_ssl. No clue why or how.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment