Commit 794393f3 authored by Jason Madden's avatar Jason Madden

workaround psutil failures on travis.

parent f7dce8bf
......@@ -8,8 +8,8 @@ coveralls>=1.0
cffi
futures
# Makes tests faster, but causes issues on the old
# linux version Travis CI uses.
# psutil
# linux version Travis CI uses. We have a workaround.
psutil
# For viewing README.rst (restview --long-description),
# CONTRIBUTING.rst, etc.
# https://github.com/mgedmin/restview
......
......@@ -633,14 +633,10 @@ def disabled_gc():
gc.enable()
try:
import psutil
except ImportError:
psutil = None
import re
# Linux/OS X/BSD platforms can implement this by calling out to lsof
import re
# Linux/OS X/BSD platforms can implement this by calling out to lsof
def _run_lsof():
def _run_lsof():
import tempfile
pid = os.getpid()
fd, tmpname = tempfile.mkstemp('get_open_files')
......@@ -653,7 +649,7 @@ except ImportError:
os.remove(tmpname)
return data
def get_open_files(pipes=False):
def get_open_files(pipes=False):
data = _run_lsof()
results = {}
for line in data.split('\n'):
......@@ -678,7 +674,7 @@ except ImportError:
results['data'] = data
return results
def get_number_open_files():
def get_number_open_files():
if os.path.exists('/proc/'):
# Linux only
fd_directory = '/proc/%d/fd' % os.getpid()
......@@ -689,13 +685,16 @@ except ImportError:
except (OSError, AssertionError):
return 0
else:
lsof_get_open_files = get_open_files
try:
import psutil
except ImportError:
# If psutil is available (it is cross-platform) use that.
# It is *much* faster than shelling out to lsof each time
# (Running 14 tests takes 3.964s with lsof and 0.046 with psutil)
# However, it still doesn't completely solve the issue on Windows: fds are reported
# as -1 there, so we can't fully check those.
# XXX: Note: installing psutil on the travis linux vm caused failures in test__makefile_refs.
def get_open_files():
results = dict()
......@@ -714,6 +713,10 @@ else:
# num_fds is unix only. Is num_handles close enough on Windows?
return 0
if RUNNING_ON_TRAVIS:
# XXX: Note: installing psutil on the travis linux vm caused failures in test__makefile_refs.
get_open_files = lsof_get_open_files
if PYPY:
def getrefcount(*args):
......
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