zoukankan      html  css  js  c++  java
  • 使用gevent时遇到的一些问题记录

    1.urllib2在python3中已经没了,使用urllib3 相应代码也要做更改

    原代码 :

    response = urllib2.urlopen(url)

    data = response.read()

    改为 

    http = urllib3.PoolManager()
    response = http.request('GET', url)
    data = response.data

    2.try except  python3中有更改

    except Exception as e:#多了个as

    3. gevent访问https时报错;

    MonkeyPatchWarning: Monkey-patching ssl after ssl has already been imported may lead to errors, including RecursionError on Python 3.6. It may also silently lead to incorrect behaviour on Python 3.7. Please monkey-patch earlier. See https://github.com/gevent/gevent/issues/1016. Modules that had direct imports (NOT patched): ['urllib3.util (D:\project\venv\lib\site-packages\urllib3\util\__init__.py)', 'urllib3.util.ssl_ (D:\project\venv\lib\site-packages\urllib3\util\ssl_.py)'].
    monkey.patch_all()

    上述链接已经说明解决方法就是 monkey.patch_all()需要在import urllib3前完成。但是这样又不符合PEP8的规范。目前还不知道有什么更完美的方法



  • 相关阅读:
    epplus
    http://www.cmake.org/
    patheditor2
    emgu cv
    OpenCV
    Tesseract
    Blendar基金会
    安装服务windows,installutil
    R 软件
    历史为什么选择C语言?事实证明:暮年的C语言,依旧宝刀未老!
  • 原文地址:https://www.cnblogs.com/3nohtyp/p/12692396.html
Copyright © 2011-2022 走看看