Skip to content

Conversation

kevinhartman
Copy link
Contributor

@kevinhartman kevinhartman commented Apr 10, 2025

Summary

This is a workaround for the deadlock error issue caused by multiple PyO3 Rust tests attempting to import things from qiskit at the same time.

Details and comments

The sitecustomize.py gets executed automatically since we add its directory to the Python path.

Originally discussed in #13776.

This way, our Rust PyO3 tests won't attempt to import qiskit
from multiple threads, which leads to deadlock errors.
@kevinhartman kevinhartman requested a review from a team as a code owner April 10, 2025 22:53
@qiskit-bot
Copy link
Collaborator

One or more of the following people are relevant to this code:

  • @Qiskit/terra-core

@jakelishman
Copy link
Member

On the basis of #13776 (comment), are Python-interacting tests still something we want to pursue?

@coveralls
Copy link

Pull Request Test Coverage Report for Build 14391803253

Details

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • 15 unchanged lines in 2 files lost coverage.
  • Overall coverage decreased (-0.006%) to 88.237%

Files with Coverage Reduction New Missed Lines %
crates/qasm2/src/lex.rs 3 92.23%
crates/qasm2/src/parse.rs 12 97.15%
Totals Coverage Status
Change from base Build 14389768512: -0.006%
Covered Lines: 73727
Relevant Lines: 83556

💛 - Coveralls

@raynelfss
Copy link
Contributor

On the basis of #13776 (comment), are Python-interacting tests still something we want to pursue?

From what I could find, I believe there might still be a use case for it, in which our Python interaction should not involved extracting any PyO3 based structures. For the case of PackedOperation and an operation from Python, there's no extractions involved. But we do still need Python to test that whatever we're doing is working as expected. For more information check out the discussion we had over here.

@jakelishman
Copy link
Member

It is possible to write tests using it, but is that necessarily the best strategy? There's a lot of infrastructure that we need to have to support this, and it's not clear to me why Python needs to be involved in that test. For a small-scale unit test, can we leave it at testing the correctness of the backing Rust object (right before extraction to Python) rather than importing Qiskit from Python space?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Changelog: None Do not include in changelog
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants