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

More PyPy tweaks.

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