Chinaunix首页 | 论坛 | 博客
  • 博客访问: 5011011
  • 博文数量: 921
  • 博客积分: 16037
  • 博客等级: 上将
  • 技术积分: 8469
  • 用 户 组: 普通用户
  • 注册时间: 2006-04-05 02:08
文章分类

全部博文(921)

文章存档

2020年(1)

2019年(3)

2018年(3)

2017年(6)

2016年(47)

2015年(72)

2014年(25)

2013年(72)

2012年(125)

2011年(182)

2010年(42)

2009年(14)

2008年(85)

2007年(89)

2006年(155)

分类: Python/Ruby

2015-07-24 10:23:46

sockjs客户端是websocket javascript库(), 可能会替代socket.io

txmysql -- 异步mysql库 

txredisapi -- 异步redis库 

txmongo -- 异步mongodb库 

txzmq -- 异步zmq库 

txsockjs -- sockjs库--  href=" target="_self" rel="nofollow" style="padding:0px;margin:0px;color:#FF8373;outline:0px;font-size:12px;">全部sockjs

其中txmysql说明:

和twisted自带的不同,这个不是通过MySQLdb+deferToThread实现的,是真正的异步,通过twisted的tcp连接到mysql服务器,使用mysql相关协议进行操作的.自带的通过线程.这个是通过异步io



  1. from txmysql import client
  2. from twisted.internet import reactor
  3. from twisted.internet.defer import inlineCallbacks
  4. from twisted.python import log
  5.  
  6. import sys
  7.  
  8. log.startLogging(sys.stdout)
  9.  
  10. @inlineCallbacks
  11. def test():
  12.     conn = client.MySQLConnection("192.168.6.234", "root", "123456", "test")
  13.     result = yield conn.runQuery("select * from book")
  14.     log.msg(result)
  15.     reactor.callLater(1, reactor.stop)
  16.  
  17. if __name__ == "__main__":
  18.     reactor.callWhenRunning(test)
  19.     reactor.run()
这些库的使用就不说了,有例子

原文链接

阅读(1568) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~