The Twisted application module defines an application Reactor class. This class is extended by actual reactor implementations that may be used within Twisted applications. Reactors that are available for installation may be enumerated over by using the getReactorTypes() function. The use of this function is illustrated below.
#Example; Enumerating reactor types.
#Import the required function.
from twisted.application.reactors import getReactorTypes
#Main.
if __name__=="__main__":
#Iterate over the reactor types.
for i in getReactorTypes():
#Display reactor information.
print i.shortName
print i.description,"\n"
As you can see, the Reactor class has three simple attributes; shortName, moduleName, and description. The moduleName is really important for installing the reactor. It tells Twisted where the actual code for the reactor can be found.
The getReactorTypes() is useful for providing choices to the user. This would actually make more sense as a configuration option for advanced users such as an administrator.
No comments :
Post a Comment