在使用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框架以及组件
https://pypi.python.org/simple/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()
原文:https://www.cnblogs.com/wqzn/p/10635429.html