在使用twisted框架的时候,我们需要知道他是干什么的?

  twisted支持很多种协议,包括传输层的TCP, UDP, TLS和引用层的HTTP和FTP等。

twisted框架其主要发行版本是以python2为主的,最新版本是基于python2.7的twisted-15.4.0,目前为止,没有基于python3的twisted稳定的发行版。

在window中,twisted的实现是基于IO操作完成端口技术。保证了底层高效的将IO时间通知给框架和应用程序。

在Linux系统中,twisted的实现基于epoll技术(epoll不限制监听的socket的次数,可以执行回调方法),epoll显著提高程序在大量的并发中,只有少数活跃的情况下提高了CPU的利用率。

安装twisted框架以及组件

  • 安装twisted的时候,要将解释器的环境切换到python2中
  • 安装twisted框:
    • https://pypi.python.org/simple/twisted

    • 里面有很多版本,最后下载exe格式的可以自动安装,我下载的版本是Twisted-15.4.0.win-amd64-py2.7.exe,安装完成后,你会在C:\Python27\Lib\site-packages目录下看到twisted文件夹
  • 安装zope.interface
  • https://pypi.python.org/simple/zope.interface/
  • 很多版本,根据windows位数,python版本号,以及exe文件傻瓜式安装,我选择的版本是 zope.interface-4.1.1.win-amd64-py2.7.exe,安装完成后,你会在C:\Python27\Lib\site-packages目录下看到zope文件夹
  • 验证安装成功
    • import twisted

如果在安装过程中出现:Python version 2.7 required, which was not found in the registry 这个错误的时候,就建立一个register.py的文件,然后执行下面的脚本。 

import sys

from _winreg import *

# tweak as necessary
version = sys.version[:3]
installpath = sys.prefix regpath = "SOFTWARE\\Python\\Pythoncore\\%s\\" % (version)
installkey = "InstallPath"
pythonkey = "PythonPath"
pythonpath = "%s;%s\\Lib\\;%s\\DLLs\\" % (
installpath, installpath, installpath
) def RegisterPy():
try:
reg = OpenKey(HKEY_CURRENT_USER, regpath)
except EnvironmentError as e:
try:
reg = CreateKey(HKEY_CURRENT_USER, regpath)
SetValue(reg, installkey, REG_SZ, installpath)
SetValue(reg, pythonkey, REG_SZ, pythonpath)
CloseKey(reg)
except:
print "*** Unable to register!"
return
print "--- Python", version, "is now registered!"
return
if (QueryValue(reg, installkey) == installpath and
QueryValue(reg, pythonkey) == pythonpath):
CloseKey(reg)
print "=== Python", version, "is already registered!"
return
CloseKey(reg)
print "*** Unable to register!"
print "*** You probably have another Python installation!" if __name__ == "__main__":
RegisterPy()

最新文章

  1. 1877: [SDOI2009]晨跑
  2. 《C++ Primer》学习笔记【第三部分 类设计者的工具】
  3. Understanding Convolutions
  4. Jenkins进阶系列之——07更改Jenkins的主目录
  5. MySQL: 详细的sql语句
  6. java去掉jsp标签内容的方法
  7. QT QXmlStreamWriter用法小结
  8. asp.net用Zxing库实现条形码输出的具体实现
  9. @RestController
  10. gdb的user-define command
  11. 完美解决浮动IE6 7中的兼容性BUG问题
  12. Boosting(提升方法)之XGBoost
  13. 老集群RAC双网卡绑定
  14. Leaf——美团点评分布式ID生成系统 UUID & 类snowflake
  15. VuePress
  16. C++调用ffmpeg.exe提取视频帧
  17. Vistual Studio Community 2017 账号的许可证过期,公安网激活方法
  18. react修改app.js添加中文内容后中文部分乱码解决
  19. docker学习实践之路[第三站]node站点部署
  20. C#------Aspose的License文件

热门文章

  1. Elasticsearch 6.2.3版本 filtered 报错问题 no [query] registered for [filtered]
  2. canvas基础知识
  3. 笔记纪要:C# WebService URL重写
  4. 结构体封装高精度 大整数BigInt
  5. USACO4.1 Fence Loops【最小环&边->点转化】
  6. 【OpenCV开发】imread和imwrite的类型以及第三个参数关于图片压缩质量等
  7. Idea 竖选文本、竖向选择、横向纵向选择文本代码
  8. Win10成功安装IIS后浏览器打开localhost正确显示的页面
  9. eclipse sts 断点不起作用,把这行 勾上 就行
  10. RSA加密 抛异常 algid parse error, not a sequence