1. 程式人生 > >安裝gevent環境,用於壓力測試

安裝gevent環境,用於壓力測試

2012-03-08

安裝gevent環境,install gevent gevent 是基於libevent和greenlet的高效能併發IO python庫,採用monkey給python中已經存在的socket,執行緒等打補丁,使其支援非同步,而不是同步等待,但使用方式卻和同步差不多。 相較twisted的回撥方式用法,更加直接。 簡單而言,只需安裝libevent-dev和greenlet,gevent三者。不過我的是新環境,所以相關環境也安裝了一下。

[email protected]:~$ cat /etc/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=10.04
DISTRIB_CODENAME=lucid
DISTRIB_DESCRIPTION="Ubuntu 10.04.3 LTS"



[email protected]
:~$ uname -a Linux ubuntu 2.6.32-33-server #70-Ubuntu SMP Thu Jul 7 22:28:30 UTC 2011 x86_64 GNU/Linux [email protected]:~$ python Python 2.6.5 (r265:79063, Apr 16 2010, 13:57:41) [GCC 4.4.3] on linux2

安裝libevent-dev

[email protected]:~$ sudo apt-get install libevent-dev

沒有easy_install,安裝setuptools

an[email protected]:~$ wget -q http://peak.telecommunity.com/dist/ez_setup.py
[email protected]:~$ sudo python ez_setup.py

遇到沒有安裝gcc,python-dev

[email protected]:~$ sudo easy_install greenlet

greenlet.c:1085: error: ‘PyObject’ undeclared (first use in this function)

error: Setup script exited with error: command 'gcc' failed with exit status 1

[email protected]
:~$ sudo apt-get install build-essential [email protected]:~$ sudo apt-get install python-dev

也可以執行sudo apt-get install python-setuptools python-pip 來安裝python 安裝工具。 可以用pip 來安裝: pip install greenlet pip install gevent 或用easy_install: 安裝greenlet

[email protected]:~$ sudo easy_install greenlet

安裝gevent

[email protected]:~$ sudo easy_install gevent

完畢

參考: http://engineering.monetate.com/do-c10k-testing-with-gevent https://bitbucket.org/denis/gevent/src/tip/examples/ http://www.gevent.org/contents.html

如非註明轉載, 均為原創. 本站遵循知識共享CC協議,轉載請註明來源