nedbat / coveragepy

The code coverage tool for Python
https://coverage.readthedocs.io
Apache License 2.0
3.01k stars 431 forks source link

COVERAGE_PROCESS_START .pth gunicorn supervisor run sucess No coverage data file #1423

Closed jokerbo1 closed 1 year ago

jokerbo1 commented 2 years ago

Describe the bug

New process: executable: /home/blibee/miniconda3/envs/robotsocketenv/bin/python
New process: cmd: None
New process: pid: 630905, parent pid: 663785
Setting context: None
-- config ----------------------------------------------------
         attempted_config_files: coverage.ini
                         branch: True
                   command_line: None
                    concurrency: None
                    config_file: /data/w/www/gaia/coverage.ini
              config_files_read: /data/w/www/gaia/coverage.ini
                        context: None
                    cover_pylib: False
                      data_file: .coverage
                          debug: config
                                 dataio
                                 dataop
                                 multiproc
                                 process
                                 sys
               disable_warnings: -none-
                dynamic_context: None
                   exclude_list: #\s*(pragma|PRAGMA)[:\s]?\s*(no|NO)\s*(cover|COVER)
                      extra_css: None
                     fail_under: 0.0
                       html_dir: htmlcov
              html_skip_covered: None
                html_skip_empty: None
                     html_title: Coverage report
                  ignore_errors: False
                    json_output: coverage.json
              json_pretty_print: False
             json_show_contexts: False
                           note: None
                       parallel: True
            partial_always_list: while (True|1|False|0):
                                 if (True|1|False|0):
                   partial_list: #\s*(pragma|PRAGMA)[:\s]?\s*(no|NO)\s*(branch|BRANCH)
                          paths: OrderedDict()
                 plugin_options: {}
                        plugins: -none-
                      precision: 0
                 relative_files: False
                report_contexts: None
                 report_include: None
                    report_omit: None
                    run_include: None
                       run_omit: None
                  show_contexts: False
                   show_missing: False
                   skip_covered: False
                     skip_empty: False
                           sort: None
                         source: None
                    source_pkgs: -none-
                          timid: False
                     xml_output: coverage.xml
              xml_package_depth: 99
-- sys -------------------------------------------------------
               coverage_version: 6.2
                coverage_module: /home/blibee/miniconda3/envs/robotsocketenv/lib/python3.6/site-packages/coverage/__init__.py
                         tracer: CTracer
                        CTracer: available
           plugins.file_tracers: -none-
            plugins.configurers: -none-
      plugins.context_switchers: -none-
              configs_attempted: coverage.ini
                   configs_read: /data/w/www/gaia/coverage.ini
                    config_file: /data/w/www/gaia/coverage.ini
                config_contents: b'[run]\nbranch=True\nparallel=True\ndebug=config,dataio,dataop,multiproc,process,sys\n'
                      data_file: /data/w/www/gaia/.coverage.aistore.ai.w.beta.bj1.wormpex.com.630905.024444
                         python: 3.6.10 |Anaconda, Inc.| (default, May  8 2020, 02:54:21) [GCC 7.3.0]
                       platform: Linux-3.10.0-862.11.6.el7.x86_64-x86_64-with-centos-7.5.1804-Core
                 implementation: CPython
                     executable: /home/blibee/miniconda3/envs/robotsocketenv/bin/python
                   def_encoding: utf-8
                    fs_encoding: utf-8
                            pid: 630905
                            cwd: /data/w/www/gaia
                           path: /home/blibee/miniconda3/envs/robotsocketenv/lib/python36.zip
                                 /home/blibee/miniconda3/envs/robotsocketenv/lib/python3.6
                                 /home/blibee/miniconda3/envs/robotsocketenv/lib/python3.6/lib-dynload
                                 /home/blibee/miniconda3/envs/robotsocketenv/lib/python3.6/site-packages
                                 /home/blibee/miniconda3/envs/robotsocketenv/lib/python3.6/site-packages/alibabacloud_nls_java_sdk-2.0.0-py3.6.egg
                                 /home/blibee/miniconda3/envs/robotsocketenv/lib/python3.6/site-packages/websocket_client-0.57.0-py3.6.egg
                    environment: COVERAGE_PROCESS_START = coverage.ini
                                 HOME = /root
                   command_line: -none-
                 coverage_paths: /home/blibee/miniconda3/envs/robotsocketenv/lib/python3.6/site-packages/coverage
                   stdlib_paths: /home/blibee/miniconda3/envs/robotsocketenv/lib/python3.6
              third_party_paths: /home/blibee/miniconda3/envs/robotsocketenv/lib/python
                                 /root/.local/lib/python3.6/site-packages
                                 /root/.local/bin
                                 /home/blibee/miniconda3/envs/robotsocketenv/lib/python3.6/site-packages
                                 /home/blibee/miniconda3/envs/robotsocketenv/bin
                   source_match: -none-
              source_pkgs_match: -none-
                  include_match: -none-
                     omit_match: -none-
                    cover_match: /home/blibee/miniconda3/envs/robotsocketenv/lib/python3.6/site-packages/coverage
                    pylib_match: /home/blibee/miniconda3/envs/robotsocketenv/lib/python3.6
                    third_match: /home/blibee/miniconda3/envs/robotsocketenv/bin
                                 /home/blibee/miniconda3/envs/robotsocketenv/lib/python
                                 /home/blibee/miniconda3/envs/robotsocketenv/lib/python3.6/site-packages
                                 /root/.local/bin
                                 /root/.local/lib/python3.6/site-packages
                sqlite3_version: 2.6.0
         sqlite3_sqlite_version: 3.31.1
             sqlite3_temp_store: 0
        sqlite3_compile_options: COMPILER=gcc-7.3.0; ENABLE_COLUMN_METADATA; ENABLE_DBSTAT_VTAB
                                 ENABLE_FTS3; ENABLE_FTS3_TOKENIZER; ENABLE_FTS4
                                 ENABLE_FTS5; ENABLE_GEOPOLY; ENABLE_JSON1
                                 ENABLE_RTREE; ENABLE_UNLOCK_NOTIFY; MAX_DEFAULT_PAGE_SIZE=32768
                                 MAX_EXPR_DEPTH=10000; MAX_VARIABLE_NUMBER=250000; SECURE_DELETE
                                 THREADSAFE=1
-- end -------------------------------------------------------

Supervisor Config:

command=/home/blibee/miniconda3/envs/robotsocketenv/bin/gunicorn -b 0.0.0.0:8011 gaia.asgi:application -w 4 -k uvicorn.workers.UvicornWorker --max-requests 1500 --max-requests-jitter 2000
user=blibee
directory=/data/w/www/gaia
process_name=%(program_name)s
priority=1
autostart=true
stdout_logfile=/data/logs/gaia_web.log
stderr_logfile=/data/logs/gaia_web_err.log
stopsignal=KILL
killasgroup=true
stopasgroup=true
environment=COVERAGE_PROCESS_START="coverage.ini"

Pth file install Path

/home/blibee/miniconda3/envs/robotsocketenv/lib/python3.6/site-packages

global_coverage.pth file content:

import coverage; coverage.process_startup()

When I run the supervisor command to restart, the coverage runs normally and no error log is found, but the corresponding coverage data file (.coverage) is not output. Please help me to see if my configuration and command execution are incorrect, causing The coverage file is not output or there are other problems. In addition, I would like to ask whether the coverage supports the celery framework coverage.

To Reproduce run application will reproduce.

Expected behavior the .coverage data file is generated at the working dir

Additional context none

nedbat commented 1 year ago

Hi, sorry it's taken me so long to get to this. I don't know what application you are running, so it might be difficult to debug. I see you have environment=COVERAGE_PROCESS_START="coverage.ini". I assume you have a coverage.ini file. Does it fix the problem to use an absolute path there instead?