nedbat / coveragepy

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

Allow user specified additional 'parallel' suffix #756

Closed ulope closed 5 years ago

ulope commented 5 years ago

Is your feature request related to a problem? Please describe. I've noticed that when running coverage in parallel mode on containerized CI systems with heavy concurrency it happens sometimes that the generated suffix is not unique (depleted entropy pool would be my guess).

Describe the solution you'd like A simple solution would be to allow the user to specify an optional additional suffix (either via cli flag or environment variable) since most CI systems already provide a unique job-id (or similar).

Describe alternatives you've considered More elaborate schemes of automatically generating the suffix (e.g. taking a hash of the environment, incorporating date/time). But those seem either a bit too complicated or could also suffer from the same problem in high concurrency situations.

nedbat commented 5 years ago

Hmm, interesting point: coverage.py uses the process id to disambiguate, but docker uses the same pids over and over. My inclination would be to have a config value that is used as the entire suffix, but I think you can do everything you need now by setting data_file with an environment variable?

[run]
data_file = .coverage_${SOMETHING_UNIQUE}

Can you give that a try and see?

ulope commented 5 years ago

Ah good idea, thanks. I'll try that.

earonesty commented 5 years ago

see: https://github.com/nedbat/coveragepy/pull/802