Skip to content

coverage.py freezes and I don't know why... #596

Open
@nedbat

Description

@nedbat

Originally reported by linwoodc3 (Bitbucket: linwoodc3, GitHub: linwoodc3)


Hello and thanks in advance for the time and consideration.

  • OS= MacOSX 10.12.6
  • '64bit'
  • Anaconda - conda 4.3.24
  • Python - 2.7.13| packaged by conda-forge and Python - 3.6.1| packaged by conda-forge

I am trying to use "coverage" in my CI builds on Appveyor (for Windows) and Travis CI (for Linux and OSX). To start off, my library (https://github.com/linwoodc3/gdeltPyR) uses multiprocessing but I don't know what the problem is.

I have tried to collect coverage reports in multiple ways. First, the successful way is when I run pytest from the root directory of my project (gdeltPyR):

$ pytest

Everything works fine and coveralls gets the report. My setup.cfg file looks like this:

[bdist_wheel]
#works with Python 2 and Python 3
universal=1

[aliases]
test=pytest

[tool:pytest]
addopts = --verbose --cov gdelt --cov-repo=term-missing
python_files = tests/*.py

In my CI scripts, I add pytest to the script section and coveralls to the "after success" section and get results. However, I am trying to use coverage but I keep getting a frozen build on Travis or Appveyor. Here is the command I use from the same root directory:

coverage run --source=gdelt setup.py test

All the tests run successfully, and all it needs to do is clse. But the run always freezes at the very end (exact same last line as pytest, but pytest finishes and this one doesn't), and I assume it has something to do with multiprocessing. If I kill the run, I get this traceback:

^CError in atexit._run_exitfuncs:
Traceback (most recent call last):
  File "/Users/linwood/anaconda3/envs/python2/lib/python2.7/atexit.py", line 24, in _run_exitfuncs
    func(*targs, **kargs)
  File "/Users/linwood/anaconda3/envs/python2/lib/python2.7/multiprocessing/util.py", line 325, in _exit_function
Exception in thread Thread-1:
Traceback (most recent call last):
  File "/Users/linwood/anaconda3/envs/python2/lib/python2.7/threading.py", line 801, in __bootstrap_inner
    self.run()
  File "/Users/linwood/anaconda3/envs/python2/lib/python2.7/threading.py", line 754, in run
    self.__target(*self.__args, **self.__kwargs)
  File "/Users/linwood/anaconda3/envs/python2/lib/python2.7/site-packages/concurrent/futures/process.py", line 208, in _queue_management_worker
    result_item = result_queue.get(block=True)
  File "/Users/linwood/anaconda3/envs/python2/lib/python2.7/multiprocessing/queues.py", line 117, in get
    res = self._recv()
EOFError

    p.join()
  File "/Users/linwood/anaconda3/envs/python2/lib/python2.7/multiprocessing/process.py", line 145, in join
    res = self._popen.wait(timeout)
  File "/Users/linwood/anaconda3/envs/python2/lib/python2.7/multiprocessing/forking.py", line 154, in wait
    return self.poll(0)
  File "/Users/linwood/anaconda3/envs/python2/lib/python2.7/multiprocessing/forking.py", line 135, in poll
    pid, sts = os.waitpid(self.pid, flag)
KeyboardInterrupt
Error in sys.exitfunc:
Traceback (most recent call last):
  File "/Users/linwood/anaconda3/envs/python2/lib/python2.7/atexit.py", line 24, in _run_exitfuncs
    func(*targs, **kargs)
  File "/Users/linwood/anaconda3/envs/python2/lib/python2.7/multiprocessing/util.py", line 325, in _exit_function
    p.join()
  File "/Users/linwood/anaconda3/envs/python2/lib/python2.7/multiprocessing/process.py", line 145, in join
    res = self._popen.wait(timeout)
  File "/Users/linwood/anaconda3/envs/python2/lib/python2.7/multiprocessing/forking.py", line 154, in wait
    return self.poll(0)
  File "/Users/linwood/anaconda3/envs/python2/lib/python2.7/multiprocessing/forking.py", line 135, in poll
    pid, sts = os.waitpid(self.pid, flag)
KeyboardInterrupt

So, I tried to set the multiprocessing param in the .coveragerc file (I just copied from coverage's docs):

# .coveragerc to control coverage.py
[run]
branch = True
concurrency = multiprocessing
parallel= True

[disable_warnings] = UserWarning

[paths]
source =
    gdelt/

[report]
# Regexes for lines to exclude from consideration
exclude_lines =
    # Have to re-enable the standard pragma
    pragma: no cover

    # Don't complain about missing debug-only code:
    def __repr__
    if self\.debug

    # Don't complain if tests don't hit defensive assertion code:
    raise AssertionError
    raise NotImplementedError

    # Don't complain if non-runnable code isn't run:
    if 0:
    if __name__ == .__main__.:

ignore_errors = True

[html]
directory = build

Any thoughts on how to get around the freeze?


Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions