Skip to content

sys.monitoring use_tool_id exception #2187

Description

@gnufede

Describe the bug
If coverage.py with the sys.monitoring API is used at the same time as another tool is using it to collect coverage, an unhandled exception will be raised:

ValueError: tool 1 is already in use

To Reproduce
Using Python 3.12+

# repro.py
import sys
import coverage


tool_id = sys.monitoring.COVERAGE_ID
sys.monitoring.use_tool_id(tool_id, "another coverage tool")

cov = coverage.Coverage(config_file=False)
cov.start()

$ COVERAGE_CORE=sysmon python repro.py

Expected behavior
The Exception is handled instead of exiting the process.

Additional context
Add any other context about the problem here.

No activity

Activity on this issue will appear here.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingfixed

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions