pytest-dev / pytest-dev/pytest-django

How does live_server know which database to connect to?

Open
#389 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
1.5k
Forks
367
PR merge metrics
No merged PRs in 30d

Description

I'm trying to wrap my head around database connection handling in Django. How does the LiveServerThread pick the right database? Am I correct in my understanding that the django settings are modified per xdist process and that the LiveServerThread picks its choice from that same modified settings object?

It seems like it would need to be communicated across the thread boundary, but perhaps I'm wrong. Any explanation would be most welcome! :)

Contributor guide

Open the contributing guide

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 tracing the named LiveServerThread and the pytest-xdist process-specific Django settings described in the issue. Verify how the database choice crosses the thread boundary, then document a clear explanation of the connection-handling behavior and whether the settings object is shared.

Written by the indexing model from the issue text.

Assessment

Tech stack
django, python
Domain
backend, databases, testing
Issue type
Documentation
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.