`put_async(Path)` opens files synchronously while holding the GIL
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 48/100
- Tipo di issue
- Bug
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Attiva
- Ambito
- backend, performance
Direzione di ricerca
Start by tracing put_async() argument extraction for native Path inputs and the Rust async upload path; the issue names no source files or tests. Check how file opening and seek based size detection interact with cancellation and multipart selection. Done means slow opens do not block the event loop or hold the GIL, with the existing reader and upload behavior preserved.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Passing a pathlib.Path to obstore.put_async() opens the file during PyO3 argument extraction, before returning the awaitable. This happens synchronously while holding the Python GIL.
If opening the file stalls, it blocks the calling event loop. Moving the call to a Python worker thread does not fully address this: the file open still holds the GIL, preventing other Python threads from progressing.
Reproduction
On Unix, a named pipe provides a deterministic way to simulate a slow open. An external process supplies data after one second:
import asyncio
import os
import subprocess
import sys
import tempfile
from pathlib import Path
import obstore
from obstore.store import MemoryStore
async def main():
with tempfile.TemporaryDirectory() as directory:
source = Path(directory) / "source"
os.mkfifo(source)
writer = subprocess.Popen([
sys.executable,
"-c",
"""
import sys
import time
time.sleep(1)
with open(sys.argv[1], "wb") as output:
output.write(b"hello")
""",
str(source),
])
async def heartbeat():
while True:
print("tick", flush=True)
await asyncio.sleep(0.1)
heartbeat_task = asyncio.create_task(heartbeat())
try:
await asyncio.sleep(0.1)
await obstore.put_async(
MemoryStore(),
"destination",
source,
use_multipart=False,
)
finally:
heartbeat_task.cancel()
await asyncio.gather(heartbeat_task, return_exceptions=True)
await asyncio.to_thread(writer.wait)
asyncio.run(main())
Observed: heartbeats stop while the file is opening.
Expected: local file preparation should not block the Python event loop or hold the GIL during blocking filesystem operations.
Possible fix
Defer opening native Path inputs until the Rust async operation runs, using tokio::task::spawn_blocking for opening and any seek-based size detection. Preserve the existing native reader and upload pipeline afterward.
A local prototype passes regression tests for event-loop responsiveness, cancellation during opening, and multipart selection. One observable behavior change is that file-opening errors would surface when awaiting the operation, rather than during the initial call.
If this fix is sound, I can open a PR with my local patch.
Reproduced with Obstore 0.11.1, CPython 3.14.7, macOS arm64.
- Lingua principale
- Python
- Stelle
- 830
- Fork
- 45
- Merge medio
- 7h 53m
- PR unite (30g)
- 13
Preparare l'ambiente
Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di developmentseed/obstore
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 75/100
developmentseed/obstore#779 · 5 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 67/100
developmentseed/obstore#778 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 50/100
developmentseed/obstore#772 ·
I maintainer di solito rispondono entro 1 giorno
-
LocalStore fsspec adding extra path stuff in WindowsForse già presa @dajiaohuang l’ha presa 17 giorni fa. Aperta
Difficoltà 3/5 1-2 giorni Idoneità per principianti 65/100
developmentseed/obstore#763 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 55/100
developmentseed/obstore#754 · 6 commenti ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di developmentseed/obstore
Issue simili
-
question
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
conda-forge/vc-feedstock#132 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
limitlessprojects/Go-Hybrid#3342 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 85/100
UKGovernmentBEIS/inspect_ai#6268 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
LSSTDESC/rail_sompz#42 ·
-
All tests fail with 'EXITED with status 3' on pytest 9.2.0 (TestReport._id is not marshallable)Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 66/100
pytest-dev/pytest-forked#113 ·