V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐学习书目
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
tdifg
V2EX  ›  Python

一开多线程用 pycurl 就挂?

  •  
  •   tdifg · 2015-10-27 15:41:31 +08:00 · 3327 次点击
    这是一个创建于 3105 天前的主题,其中的信息可能已经有所发展或是发生改变。

    最近赶个工,需要取延时信息,所以必须用 curl 。

    核心部分很简单,就是多线程(我用了 threadpool)用 curl 跑 url 列表,结果我这里经常直接 exit code 139 ,看下 core dump ,貌似是 perform 过程中挂的。磨蹭了一上午,一气之下直接换用了 for 循环……竟然就正常了
    你们碰过这种事吗?

    6 条回复    2015-12-14 12:39:48 +08:00
    loqixh
        1
    loqixh  
       2015-10-27 15:55:17 +08:00
    libcurl 的多线程有点麻烦,很多库没处理。。。。。。。退出正常
    dai269619118
        2
    dai269619118  
       2015-10-27 16:31:30 +08:00
    我用进程池跑 pycurl 也有这个问题- -
    tdifg
        3
    tdifg  
    OP
       2015-10-28 17:09:46 +08:00
    @dai269619118
    @loqixh 我从某个犄角旮旯里翻了个设置:
    c.setopt(pycurl.NOSIGNAL, True)
    加上这个就没问题了,没有测试其他库,至少用 threadpool 是正常了。
    不清楚为啥,以后有空该读读 threadpool 代码。
    dai269619118
        4
    dai269619118  
       2015-10-28 21:12:10 +08:00
    @tdifg 擦 我加上试试
    tdifg
        5
    tdifg  
    OP
       2015-12-14 12:25:38 +08:00
    @dai269619118
    @loqixh
    然而,一个月过去了,程序前几天突然挂了,看了下进程状态,应该是多线程出了问题。所以,最好不要多线程调 pycurl 。
    唉……
    dai269619118
        6
    dai269619118  
       2015-12-14 12:39:48 +08:00
    @tdifg 现在用 supervisor 管理起来 还没出现过问题
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   1092 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 26ms · UTC 18:19 · PVG 02:19 · LAX 11:19 · JFK 14:19
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.