Skip to content
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

[feature.py3] ResourceWarning warnings on exit of tests #391

Closed
msabramo opened this issue Feb 25, 2014 · 6 comments
Closed

[feature.py3] ResourceWarning warnings on exit of tests #391

msabramo opened this issue Feb 25, 2014 · 6 comments
Labels

Comments

@msabramo
Copy link
Contributor

Discovered in PR #390, which probably can be closed.

There are number of ResourceWarning warnings on exit of tests:

$ PYTHONWARNINGS="d" .tox/py33/bin/python setup.py test -q
setup.py:32: ResourceWarning: unclosed file <_io.TextIOWrapper name='/Users/marca/dev/git-repos/supervisor/README.rst' mode='r' encoding='UTF-8'>
  README = open(os.path.join(here, 'README.rst')).read()
setup.py:33: ResourceWarning: unclosed file <_io.TextIOWrapper name='/Users/marca/dev/git-repos/supervisor/CHANGES.txt' mode='r' encoding='UTF-8'>
  CHANGES = open(os.path.join(here, 'CHANGES.txt')).read()
setup.py:52: ResourceWarning: unclosed file <_io.TextIOWrapper name='/Users/marca/dev/git-repos/supervisor/supervisor/version.txt' mode='r' encoding='UTF-8'>
  supervisor_version = open(version_txt).read().strip()
running test
running egg_info
writing supervisor.egg-info/PKG-INFO
writing top-level names to supervisor.egg-info/top_level.txt
writing entry points to supervisor.egg-info/entry_points.txt
writing dependency_links to supervisor.egg-info/dependency_links.txt
writing requirements to supervisor.egg-info/requires.txt
reading manifest file 'supervisor.egg-info/SOURCES.txt'
writing manifest file 'supervisor.egg-info/SOURCES.txt'
running build_ext
..................................................................................................../Users/marca/dev/git-repos/supervisor/supervisor/dispatchers.py:300: ResourceWarning: unclosed file <_io.TextIOWrapper name='/tmp/foo' mode='a' encoding='UTF-8'>
  backups=backups,
............................................./Users/marca/dev/git-repos/supervisor/supervisor/dispatchers.py:147: ResourceWarning: unclosed file <_io.TextIOWrapper name='/tmp/foo' mode='a' encoding='UTF-8'>
  backups=backups)
................../Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/unittest/case.py:384: ResourceWarning: unclosed file <_io.TextIOWrapper name='/tmp/log' mode='a' encoding='UTF-8'>
  function()
......................................................................../Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/unittest/case.py:384: ResourceWarning: unclosed file <_io.BufferedReader name='/var/folders/gw/w0clrs515zx9x_55zgtpv4mm0000gp/T/tmpm5x4ab'>
  function()
./Users/marca/dev/git-repos/supervisor/.tox/py33/lib/python3.3/importlib/_bootstrap.py:967: ResourceWarning: unclosed file <_io.BufferedReader name='/var/folders/gw/w0clrs515zx9x_55zgtpv4mm0000gp/T/tmpz_kn26'>
  found = marshal.loads(bytes_data)
/Users/marca/dev/git-repos/supervisor/.tox/py33/lib/python3.3/importlib/_bootstrap.py:967: ResourceWarning: unclosed file <_io.BufferedReader name='/var/folders/gw/w0clrs515zx9x_55zgtpv4mm0000gp/T/tmp6p29tz'>
  found = marshal.loads(bytes_data)
.........................../Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/unittest/case.py:384: ResourceWarning: unclosed file <_io.TextIOWrapper name='/var/folders/gw/w0clrs515zx9x_55zgtpv4mm0000gp/T/tmp3odky2/thelog' mode='a' encoding='UTF-8'>
  function()
../Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/unittest/case.py:384: ResourceWarning: unclosed file <_io.TextIOWrapper name='/var/folders/gw/w0clrs515zx9x_55zgtpv4mm0000gp/T/tmpxyr5pb/thelog' mode='w' encoding='UTF-8'>
  function()
................../Users/marca/dev/git-repos/supervisor/supervisor/dispatchers.py:147: ResourceWarning: unclosed file <_io.TextIOWrapper name='stdout_logfile' mode='a' encoding='UTF-8'>
  backups=backups)
/Users/marca/dev/git-repos/supervisor/supervisor/dispatchers.py:147: ResourceWarning: unclosed file <_io.TextIOWrapper name='stderr_logfile' mode='a' encoding='UTF-8'>
  backups=backups)
........................................................................................................................................................................................................................................................................................................./Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/unittest/case.py:135: ResourceWarning: unclosed <supervisor.medusa.text_socket.text_socket object, fd=5, family=2, type=1, proto=0>
  callable_obj(*args, **kwargs)
..../Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/unittest/case.py:135: ResourceWarning: unclosed <supervisor.medusa.text_socket.text_socket object, fd=4, family=1, type=1, proto=0>
  callable_obj(*args, **kwargs)
................................................................................................................/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/cProfile.py:102: ResourceWarning: unclosed file <_io.TextIOWrapper name='/var/folders/gw/w0clrs515zx9x_55zgtpv4mm0000gp/T/tmpaxl5vz/log' mode='a' encoding='UTF-8'>
  self.stats[func] = cc, nc, tt, ct, callers
...........................................................
----------------------------------------------------------------------
Ran 755 tests in 2.794s

OK
sys:1: ResourceWarning: unclosed file <_io.TextIOWrapper name='/var/folders/gw/w0clrs515zx9x_55zgtpv4mm0000gp/T/tmpkhnama/log' mode='a' encoding='UTF-8'>
@msabramo
Copy link
Contributor Author

I just discovered that the change in PR #382 fixes 4 of the ResourceWarning warnings:

$ PYTHONWARNINGS="d" .tox/py33/bin/nosetests -q 2>&1 | grep -c ResourceWarning
14

$ git checkout feature.py3.tox_use_nosetests_and_posargs_and_prevent_DummyLogger_from_creating_files
Switched to branch 'feature.py3.tox_use_nosetests_and_posargs_and_prevent_DummyLogger_from_creating_files'

$ PYTHONWARNINGS="d" .tox/py33/bin/nosetests -q 2>&1 | grep -c ResourceWarning
10

so that or something like it will help to clean up these warnings.

@msabramo
Copy link
Contributor Author

For the 10 ResourceWarning warnings that are not fixed by #382, here's what tests cause them:

  • supervisor.tests.test_dispatchers -- 1
  • supervisor.tests.test_http -- 3
  • supervisor.tests.test_loggers -- 2
  • supervisor.tests.test_socket_manager -- 2
  • supervisor.tests.test_supervisord -- 2

@msabramo
Copy link
Contributor Author

PR #392 eliminates the 3 ResourceWarning warnings from supervisor.tests.test_http.

With no changes, feature.py3 has 13 of these warnings.

With PR #382, that gets it down to 9.

With PR #382 and PR #392, that gets it down to 6.

msabramo added a commit to msabramo/supervisor that referenced this issue Feb 25, 2014
Eliminates 5 of the `ResourceWarning` warnings mention in SupervisorGH-391
msabramo added a commit to msabramo/supervisor that referenced this issue Feb 25, 2014
Eliminates 5 of the `ResourceWarning` warnings mentioned in SupervisorGH-391.
@msabramo
Copy link
Contributor Author

With PR #382, PR #392, and PR #393, that gets it down to 3.

msabramo added a commit to msabramo/supervisor that referenced this issue Feb 25, 2014
Fixes 2 of the `ResourceWarning` warnings in SupervisorGH-391.
@msabramo
Copy link
Contributor Author

With PR #382, PR #392, PR #393, and PR #394 that gets it down to 2.

msabramo added a commit to msabramo/supervisor that referenced this issue Feb 25, 2014
supervisor/datatypes.py

Fixes 2 of the `ResourceWarning` warnings in SupervisorGH-391.
@msabramo
Copy link
Contributor Author

PR #395 fixes the last two ResourceWarnings.

$ PYTHONWARNINGS="d" .tox/py33/bin/nosetests -q
/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/unittest/case.py:135: ResourceWarning: unclosed <supervisor.medusa.text_socket.text_socket object, fd=7, family=2, type=1, proto=0>
  callable_obj(*args, **kwargs)
/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/unittest/case.py:135: ResourceWarning: unclosed <supervisor.medusa.text_socket.text_socket object, fd=4, family=1, type=1, proto=0>
  callable_obj(*args, **kwargs)
----------------------------------------------------------------------
Ran 770 tests in 2.792s

OK

$ git merge feature.py3.fix_two_unclosed_sockets_on_errors
Merge made by the 'recursive' strategy.
 supervisor/datatypes.py | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

 $ PYTHONWARNINGS="d" .tox/py33/bin/nosetests -q
----------------------------------------------------------------------
Ran 770 tests in 2.777s

OK

With PR #382, PR #392, PR #393, PR #394, and PR #395 that gets it down to 0!

msabramo added a commit to msabramo/supervisor that referenced this issue Feb 26, 2014
supervisor/datatypes.py

Fixes 2 of the `ResourceWarning` warnings in SupervisorGH-391.
mnaberez pushed a commit that referenced this issue Mar 2, 2014
Fixes 2 of the `ResourceWarning` warnings in GH-391.
mnaberez pushed a commit that referenced this issue Mar 2, 2014
Fixes 2 of the `ResourceWarning` warnings in GH-391.
msabramo added a commit to msabramo/supervisor that referenced this issue Apr 16, 2014
supervisor/datatypes.py

Fixes 2 of the `ResourceWarning` warnings in SupervisorGH-391.
mnaberez pushed a commit that referenced this issue Aug 9, 2015
supervisor/datatypes.py

Fixes 2 of the `ResourceWarning` warnings in GH-391.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

2 participants