pytest-dev / pytest-dev/pytest-xdist

Lock not take effect while being used in test run parallelly.

Open
#668 9 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
1.9k
Forks
287
Avg merge
9h 30m
Merged PRs (30d)
2

Description

Hi, I was trying to run some test cases that needs to be run with resource exclusive while others in parallel execution. The way I prevent each worker process to access the resource is putting a lock by using python's Lock object, like:

lock.acquire() #do something exclusive lock.release()
the lock is created either in a session wide fixture or global variable in the .py file, but neither take effect. I was wonder if lock itself work with x-dist?

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the reported behavior with pytest-xdist and Python's Lock across parallel workers, using the session-wide fixture or module-level global described in the issue. Trace how workers are created and how fixtures are initialized, then establish whether the lock can be shared between processes. Done means the behavior is explained and, if appropriate, covered by a regression test or documented limitation.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
distributed-systems, testing-qa
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.