Skip to content

Make async lock initialization thread-safe - #2073

Open
Sanjays2402 wants to merge 1 commit into
fsspec:masterfrom
Sanjays2402:fix/thread-safe-async-lock
Open

Make async lock initialization thread-safe#2073
Sanjays2402 wants to merge 1 commit into
fsspec:masterfrom
Sanjays2402:fix/thread-safe-async-lock

Conversation

@Sanjays2402

Copy link
Copy Markdown
Contributor

get_lock() lazily initialized the module lock without synchronization, so concurrent first callers could receive different locks and initialize duplicate I/O loops. Initialize the process-local lock eagerly, recreate it after fork, and cover the race with a deterministic two-thread test.

Closes #1783

Tests: pytest -q (1493 passed, 215 skipped, 2 xfailed)

Eagerly create the process-local lock so concurrent first callers cannot
receive different lock objects. Recreate it after fork and add a
deterministic concurrent regression test.

Fixes fsspec#1783
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Thread safety of get_lock in asyn.py

1 participant