Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Table of Contents

In order to capture code coverage on your backend server, you need to run it using our Python test listener agent

Note

The below commands assume the token and session id are located in the working directory. If not, you can provide the location to them file locations using the sl.tokenFile and sl.buildSessionIdFile environment variables

uWSGI

When working with uWSGI, you need to run uWSGI it with the following flags either in the command line or in the uwsgi configuration file: --enable-threads  --single-interpreter --lazy-apps --import python_agent.init

...

If you need to pass the parameters via the CLI, the command line will be similar to this

Code Block
uwsgi ... --enable-threads  --single-interpreter --import python_agent.init

...

If using the uWSGI config file option, the content should look like the sample below

Code Block
[uwsgi]
...
enable-threads = true
single-interpreter = true
import = python_agent.init

...

When working with Gunicorn WSGI you need to run it with the following a configuration file which contains an import of the SeaLights Python agent in the post_fork section

...

Code Block
...
def post_fork(server, worker):
    import python_agent.init
...

...

For other servers, run with the SeaLights Python agent and the run flags

...

Code Block
sl-python run {--cov-report /path/to/report.xml --labid Lab1} <your server and args...>
Info

The first parameter after the run command should be an executable file