Skip to content

Second CoverageData.update into no_disk destination fails: other_db is already in use #2279

Description

@iskandr

Summary

With coverage.py 7.16.0 on Python 3.12.6/macOS arm64, the second CoverageData.update() into an in-memory destination raises DataError: ... database other_db is already in use.

Reproducer

from coverage import CoverageData
from pathlib import Path
from tempfile import TemporaryDirectory

with TemporaryDirectory() as root:
    combined = CoverageData(no_disk=True)
    for index in range(2):
        source = CoverageData(basename=str(Path(root) / str(index)))
        source.add_lines({"example.py": {index + 1}})
        source.write()
        combined.update(source)
    print(combined.lines("example.py"))

Expected: the merged line numbers [1, 2].

Actual: the second call fails in coverage/sqldata.py at ATTACH DATABASE ? AS other_db, with sqlite3.OperationalError: database other_db is already in use, surfaced as coverage.exceptions.DataError.

A disk-backed destination works with the same inputs. Found while adding complete matrix-coverage aggregation to openvax/topiary; that implementation uses a temporary disk-backed database.

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

    apiRelating to the public APIbugSomething isn't workingfixed

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions