V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
推荐学习书目
Learn Python the Hard Way
Python Sites
PyPI - Python Package Index
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
xxm459259
V2EX  ›  Python

请教一个 Python 多进程的问题

  •  
  •   xxm459259 · Oct 1, 2016 · 2693 views
    This topic created in 3495 days ago, the information mentioned may be changed or developed.

    RT ,弱鸡请教个 Python 多进程的问题。

    代码中多进程使用的是 subprocess.Popen() 函数, args 接受的参数是可执行文件参数

    用起来倒是没问题,现在打包提交到 pypi 上的时候别人 pip 安装后,这个可执行文件的路径也就变成了 /usr/local/lib/python2.7/dist-packages/xxx/yyy.py ,于是这个 yyy.py 也就需要权限才能给 Popen 使用……

    问问各位有没有什么好的办法能绕过这个…

    10 replies    2016-10-03 15:25:08 +08:00
    thekoc
        1
    thekoc  
       Oct 1, 2016
    方法就是不要用 subprocess.Popen() 函数…
    tempdban
        2
    tempdban  
       Oct 1, 2016
    +1
    21grams
        3
    21grams  
       Oct 2, 2016
    你在另一个 process 执行的不也是 python 吗? 不需要用 popen 啊。
    264768502
        4
    264768502  
       Oct 2, 2016 via iPad
    都是 py ,为什么多进程不用 multiprocess?
    julyclyde
        5
    julyclyde  
       Oct 2, 2016
    不理解你的描述
    什么叫“于是……也需要权限”?
    xxm459259
        6
    xxm459259  
    OP
       Oct 2, 2016
    @julyclyde 需要 root 呀。。。
    julyclyde
        7
    julyclyde  
       Oct 2, 2016
    @pandachow popen 只需要 read 权限啊
    xxm459259
        8
    xxm459259  
    OP
       Oct 2, 2016
    @julyclyde 啊?需要 +x 的呀……
    julyclyde
        9
    julyclyde  
       Oct 2, 2016
    @pandachow 哦,理解你的意思了。你是把它当做独立命令来用的。你试试 popen python xxx.py 这样呢?就不需要+x 了
    ryd994
        10
    ryd994  
       Oct 3, 2016 via Android
    为什么不做成模块然后 multi processing 调用函数呢?
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   5658 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 68ms · UTC 06:50 · PVG 14:50 · LAX 23:50 · JFK 02:50
    ♥ Do have faith in what you're doing.