MagicStack / MagicStack/uvloop

create_subprocess_shell does not have the user parameter that asyncio has

Đang mở
#618 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Ngôn ngữ chính
Cython
Star
11.9k
Fork
616
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

  • uvloop version: 0.20.0
  • Python version: 3.12.3
  • Platform: Ubuntu 24
  • Can you reproduce the bug with PYTHONASYNCIODEBUG in 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!

Hướng dẫn đóng góp

Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Hướng nghiên cứu

Bắt đầu với phần triển khai create_subprocess_shell của uvloop và so sánh các đối số được chấp nhận với tài liệu subprocess của Python asyncio. Tái hiện ví dụ được cung cấp trên uvloop và xác nhận rằng tham số user được chấp nhận và hoạt động nhất quán với asyncio mà không gây ra unexpected-keyword TypeError.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
python
Lĩnh vực
api, backend
Loại issue
Lỗi
Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Khá rõ ràng
Mức phù hợp với người mới
45/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.