coveragepy icon indicating copy to clipboard operation
coveragepy copied to clipboard

coverage API in a gunicorn wsgi django server not working

Open prabodh1194 opened this issue 4 years ago • 2 comments

Describe the bug I am using the coverage 5.5 API to run code coverage on my server. This server is written using Django.

I have implemented the solution as per this answer -- https://stackoverflow.com/a/20689873/2996407

When I start up my server on my localhost using manage.py runserver and then shut it after some time, the code coverage report is generated as expected and correctly indicates the code coverage as well.

However, on my firm's staging env, the server is run as a docker container wherein 8 gunicorn workers are spawned. 8 individual coverage files are being generated as per the solution above which is expected as well. However, the report doesn't have any coverage. The only coverage that is being done is of empty __init__.py files.

The above SO answer suggests using a single gunicorn worker, but I don't have the option to do that. However, it suggests creating coverage files per worker which is happening as expected. But no luck in getting the coverage report from those.

I started the gunicorn server on my Mac and coverage is coming in fine. However, on the staging env which runs Ubuntu, there is no coverage. Can it be an OS related issue?

To Reproduce How can we reproduce the problem? Please be specific. Don't just link to a failing CI job. Answer the questions below:

  1. Python 2.7
  2. What version of coverage.py are you using? 5.5
  3. Django 1.8
  4. /usr/local/bin/python /usr/local/bin/gunicorn users_service.wsgi:application -w=8 -b 0.0.0.0:8000 --timeout 120

Expected behavior Expected coverage to be generated.

Additional context Add any other context about the problem here.

prabodh1194 avatar May 28 '21 16:05 prabodh1194