theskumar / theskumar/python-dotenv
find_dotenv() fails when it is the target of a thread
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 8.9k
- Forks
- 581
- PR merge metrics
- No merged PRs in 30d
Description
Invoking load_dotenv as the target of a thread effectively does nothing because find_dotenv is unable to locate the local .env file.
import dotenv
threading.Thread(target=dotenv.load_dotenv).start()
This is because find_dotenv() walks the stack frames of its callers to figure out where the .env file might be located, but when load_dotenv() is the top frame in the call stack, find_dotenv cannot figure out where .env is. A simple workaround is to wrap load_dotenv in another function.
def load():
dotenv.load_dotenv()
threading.Thread(target=load).start()
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the find_dotenv and load_dotenv entry points described in the issue, and reproduce the threaded call with a local .env file. Trace how find_dotenv identifies the caller when load_dotenv is the thread target. Done means the threaded invocation locates the local file and has regression coverage.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- devops
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100