推荐学习书目
› 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
phuslu
V2EX  ›  Python

gevent 写并发程序还是蛮顺手的。

  •  
  •   phuslu · Aug 25, 2012 · 9981 views
    This topic created in 5184 days ago, the information mentioned may be changed or developed.
    打算写一个 google 北京的 hosts ip 枚举程序,稍微考虑了下,发现还是 gevent 实现方便。

    代码如下,跑起来很欢畅的~
    20 replies  •  1970-01-01 08:00:00 +08:00
    INT21H
    INT21H
    Aug 25, 2012
    1
    这个直接用 threading 就可以了吧?
    ratazzi
    ratazzi
    PRO
    Aug 25, 2012
    2
    @INT21H gevent 是更轻量的方式
    alsotang
    alsotang
    Aug 25, 2012
    3
    @ratazzi 可以细说一下为何gevent更轻量级吗?
    ratazzi
    ratazzi
    PRO
    Aug 26, 2012
    4
    @alsotang 你搜一下 greenlet 就知道了,简单来说就是所谓的微线程,网上很多介绍的
    yaotian
    yaotian
    Aug 26, 2012
    5
    @ratazzi 刚才看了一下,感觉不是微线程吧
    ratazzi
    ratazzi
    PRO
    Aug 26, 2012
    6
    @yaotian 也有称作协程的,现在貌似没有一个很权威的中文叫法吧,反正比线程轻量是一定的,不知道你认为是什么呢?
    ipconfiger
    ipconfiger
    Aug 26, 2012
    7
    别用DNS一切都ok
    phuslu
    phuslu
    OP
    Aug 26, 2012
    8
    改了一下,获取的 ip 更有效了。
    phuslu
    phuslu
    OP
    Aug 26, 2012
    9
    @ipconfiger gevent 1.0 已经修复 DNS errno 66/67 的问题了。
    weiqiyiji
    weiqiyiji
    Aug 27, 2012
    10
    我一般用gevent只patch ssl和socket,其他的都不patch
    phuslu
    phuslu
    OP
    Oct 23, 2012
    11
    改了一下, 不止搜索证书为 *.google.com 了, 只要是 google.com 的都输出了.
    tonyseek
    tonyseek
    Oct 24, 2012
    12
    `except ... pass` 看着非常不舒服
    clino
    clino
    Oct 24, 2012
    13
    枚举出来的 ip 也都不能用呀...
    phuslu
    phuslu
    OP
    Oct 24, 2012
    14
    @clino 呃, 不能用是指?
    clino
    clino
    Oct 24, 2012
    15
    @phuslu 用在 /etc/hosts 里不行啊,直接用 http://ip 也连不上呀
    phuslu
    phuslu
    OP
    Oct 24, 2012
    16
    @clino 嗯, 可能是你的网络环境(ISP?)的问题, wget http://ip 可以用吗?
    clino
    clino
    Oct 24, 2012
    17
    @phuslu 汗,我在家想试试看,结果就完全没有 ip 出来,可能你设的这个网段已经屏蔽光了
    phuslu
    phuslu
    OP
    Oct 24, 2012
    18
    @clino 换成 46.x 47.x 48.x 等网段试下呢
    cmsee
    cmsee
    Nov 6, 2012
    19
    203.208.47.2
    203.208.47.4
    203.208.47.8
    203.208.47.1
    203.208.47.22
    203.208.47.28
    203.208.47.33
    203.208.47.68
    203.208.47.32
    203.208.47.23
    203.208.47.25
    203.208.47.20
    203.208.47.5
    203.208.47.29
    203.208.47.37
    203.208.47.66
    203.208.47.133
    203.208.47.136
    203.208.47.146
    203.208.47.31
    203.208.47.6
    203.208.47.17
    203.208.47.19
    203.208.47.159
    203.208.47.130


    203.208.46.16
    203.208.46.23
    203.208.46.24
    203.208.46.30
    203.208.46.32
    203.208.46.27
    203.208.46.129
    203.208.46.33
    203.208.46.128
    203.208.46.28
    203.208.46.20
    203.208.46.131
    203.208.46.34
    203.208.46.7
    203.208.46.198
    203.208.46.200
    203.208.46.201
    203.208.46.209
    203.208.46.243
    203.208.46.152
    203.208.46.214
    203.208.46.246
    203.208.46.241
    203.208.46.210
    203.208.46.197
    203.208.46.225
    203.208.46.194
    203.208.46.242
    203.208.46.199
    203.208.46.208
    203.208.46.213
    203.208.46.245
    203.208.46.224
    203.208.46.229
    203.208.46.25
    stary
    stary
    Feb 17, 2013
    20
    大哥,这个不能用了restart,Python 2.7.3 (default, Apr 10 2012, 23:31:26) [MSC v.1500 32 bit (Intel)] on win32
    Type "copyright", "credits" or "license()" for more information.
    >>> ================================ RESTART ================================
    >>>

    >>> ================================ RESTART ================================
    >>> ,如何处理?多谢!
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   2804 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 55ms · UTC 14:11 · PVG 22:11 · LAX 06:11 · JFK 09:11
    ♥ Do have faith in what you're doing.