greecket - a python not block socket module base the greenlet and thread - Google Project Hosting
2013-01-08 18:30
417 查看
greecket - a python not block socket module base the greenlet and thread - Google Project Hosting
greecket,基於greenlet和threading的python非阻塞模式socket模塊。
the greecket uer mail list:
web:http://groups.google.com/group/greecket
mail:greecket@googlegroups.com
example
greecket_test.py
the greecket uer mail list:
web:http://groups.google.com/group/greecket
mail:greecket@googlegroups.com
example
greecket_test.py
#!/usr/bin/env python #!coding=utf-8 import greecket import sys def onConnecting(evt): print 'connecting',evt.AsList def onConnected(evt): print 'connected',evt.AsList evt.Data.send('dfsdfsfsfff') pass def onReceive(event): print 'data receive:',event.AsList def onError(evt): print 'error:',evt.AsList print evt.Data.args[1] pass def onClose(evt): print 'close',evt.AsList def runasserver(address):#host='localhost',port=5423): factory=greecket.Factory(address) print 'server',factory factory.bind(greecket.GREE_CONNECTING,onConnecting) factory.bind(greecket.GREE_CONNECTIONMADE,onConnected) factory.bind(greecket.GREE_DATARECEIVED,onReceive) factory.bind(greecket.GREE_CONNECTIONLOST,onClose) factory.bind(greecket.GREE_ERROR,onError) factory.listen() return factory def client(address): factory=greecket.Factory(address) print 'client',factory factory.bind(greecket.GREE_CONNECTING,onConnecting) factory.bind(greecket.GREE_CONNECTIONMADE,onConnected) factory.bind(greecket.GREE_DATARECEIVED,onReceive) factory.bind(greecket.GREE_CONNECTIONLOST,onClose) factory.bind(greecket.GREE_ERROR,onError) factory.bind(greecket.GREE_DATARECEIVED,onReceive) factory.bind(greecket.GREE_ERROR,onError) factory.connect() return factory if __name__=='__main__': print sys.argv if len(sys.argv)>2: d=tuple((sys.argv[-2],int(sys.argv[-1]))) else: d=('localhost',5423) if 'server' in sys.argv: f=runasserver(d) else: f=client(d) f.mainLoop()
相关文章推荐
- IntegrationWithDjango - modwsgi - How to use Django with mod_wsgi. - Python WSGI adapter module for Apache. - Google Project Hosting
- Python: The _imagingft C module is not installed错误的解决
- 【python】升级pip后报错解决pkg_resources.DistributionNotFound: The 'pip==7.1.0' distribution was not found and is required by the application
- virtualenvwrapper.sh: There was a problem running the initialization hooks. If Python could not import the module virtualenvwrapper.hook_loader, check
- Python3下的ssl certificate:Can't connect to HTTPS URL because the SSL module is not available.问题解决
- Python——eventlet.greenthread
- python socket send 错误:TypeError: 'str' does not support the buffer interface
- Python图片处理PIL/pillow/生成验证码/出现KeyError: 和The _imagingft C module is not installed
- Error:Unable to make the module:***, related gradle configuration was not found. Please, re-import the Gradle project and try again.
- Python 的PIL,可以解决ImportError The _imagingft C module is not installed
- OpenCV3.1 + Python2.7 error "DLL load failed: The specified module could not be found"
- Python安装Imaging报错:The _imaging C module is not installed问题解决方法
- Python: The _imagingft C module is not installed错误的解决
- Python中ModuleNotFoundError: No module named 'SocketServer'问题解决
- Python安装Imaging报错:The _imaging C module is not installed问题解决方法
- Python图片处理PIL/pillow/生成验证码/出现KeyError: 和The _imagingft C module is not installed
- psutil - A cross-platform process and system utilities module for Python - Google Project Hosting
- pip is configured with locations that require TLS/SSL, however the ssl module in Python is not avail
- Python图片处理PIL/pillow/生成验证码/出现KeyError: 和The _imagingft C module is not installed
- pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.