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