You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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'
importasyncioimportgetpassimportuvloopasyncdefrun(cmd, user: None|int|str=getpass.getuser()):
proc=awaitasyncio.create_subprocess_shell(
cmd,
stdout=asyncio.subprocess.PIPE,
stderr=asyncio.subprocess.PIPE,
user=user,
)
stdout, stderr=awaitproc.communicate()
print(f"[{cmd!r} exited with {proc.returncode}]")
ifstdout:
print(f"[stdout]\n{stdout.decode()}")
ifstderr:
print(f"[stderr]\n{stderr.decode()}")
asyncio.run(run("ls /tmp")) # this worksuvloop.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!
The text was updated successfully, but these errors were encountered:
PYTHONASYNCIODEBUG
in env?: yesBelow 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'
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!
The text was updated successfully, but these errors were encountered: