MagicStack / MagicStack/uvloop
create_subprocess_shell does not have the user parameter that asyncio has
Nessuno ha ancora preso questa issue.
- Lingua principale
- Cython
- Stelle
- 11.9k
- Fork
- 616
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Descrizione
- uvloop version: 0.20.0
- Python version: 3.12.3
- Platform: Ubuntu 24
- Can you reproduce the bug with
PYTHONASYNCIODEBUGin env?: yes - Does uvloop behave differently from vanilla asyncio? How?: yes
Below is a slightly modified minimal example from the stdlib, with the addition of the user parameter.
https://docs.python.org/3/library/asyncio-subprocess.html
It will work with asyncio, but the parameter is missing for uvloop in the corresponding method:
TypeError: __subprocess_run() got an unexpected keyword argument 'user'
import asyncio
import getpass
import uvloop
async def run(cmd, user: None | int | str = getpass.getuser()):
proc = await asyncio.create_subprocess_shell(
cmd,
stdout=asyncio.subprocess.PIPE,
stderr=asyncio.subprocess.PIPE,
user=user,
)
stdout, stderr = await proc.communicate()
print(f"[{cmd!r} exited with {proc.returncode}]")
if stdout:
print(f"[stdout]\n{stdout.decode()}")
if stderr:
print(f"[stderr]\n{stderr.decode()}")
asyncio.run(run("ls /tmp")) # this works
uvloop.install()
asyncio.run(run("ls /tmp")) # this errors
Could this be fixed/enhanced? This is very useful for scenarios where both changing the user and environment variables are required, since doing "su" to another user does not transfer the environment variables, and it then needs to be handled in a rather tedious way.
Thank you!
Guida per i contributori
Nessuna guida per i contributori indicizzata per questo repository
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.
Direzione di ricerca
Inizia dall’implementazione di create_subprocess_shell di uvloop e confronta gli argomenti accettati con la documentazione dei subprocess di Python asyncio. Riproduci l’esempio fornito su uvloop e conferma che il parametro user venga accettato e si comporti in modo coerente con asyncio senza sollevare il unexpected-keyword TypeError.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- python
- Ambito
- api, backend
- Tipo di issue
- Bug
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 45/100