K2LL33D SHELL

 Apache/2.4.7 (Ubuntu)
 Linux sman1baleendah 3.13.0-24-generic #46-Ubuntu SMP Thu Apr 10 19:11:08 UTC 2014 x86_64
 uid=33(www-data) gid=33(www-data) groups=33(www-data)
 safemode : OFF
 MySQL: ON | Perl: ON | cURL: OFF | WGet: ON
  >  / usr / lib / python2.7 / dist-packages / twisted / application /
server ip : 104.21.89.46

your ip : 172.70.126.203

H O M E


Filename/usr/lib/python2.7/dist-packages/twisted/application/reactors.py
Size2.07 kb
Permissionrw-r--r--
Ownerroot : root
Create time27-Apr-2025 09:56
Last modified14-Jul-2013 14:29
Last accessed06-Jul-2025 23:36
Actionsedit | rename | delete | download (gzip)
Viewtext | code | image
# -*- test-case-name: twisted.test.test_application -*-
# Copyright (c) Twisted Matrix Laboratories.
# See LICENSE for details.

"""
Plugin-based system for enumerating available reactors and installing one of
them.
"""

from zope.interface import Interface, Attribute, implements

from twisted.plugin import IPlugin, getPlugins
from twisted.python.reflect import namedAny


class IReactorInstaller(Interface):
"""
Definition of a reactor which can probably be installed.
"""
shortName = Attribute("""
A brief string giving the user-facing name of this reactor.
""")

description = Attribute("""
A longer string giving a user-facing description of this reactor.
""")

def install():
"""
Install this reactor.
"""

# TODO - A method which provides a best-guess as to whether this reactor
# can actually be used in the execution environment.



class NoSuchReactor(KeyError):
"""
Raised when an attempt is made to install a reactor which cannot be found.
"""


class Reactor(object):
"""
@ivar moduleName: The fully-qualified Python name of the module of which
the install callable is an attribute.
"""
implements(IPlugin, IReactorInstaller)


def __init__(self, shortName, moduleName, description):
self.shortName = shortName
self.moduleName = moduleName
self.description = description


def install(self):
namedAny(self.moduleName).install()



def getReactorTypes():
"""
Return an iterator of L{IReactorInstaller} plugins.
"""
return getPlugins(IReactorInstaller)



def installReactor(shortName):
"""
Install the reactor with the given C{shortName} attribute.

@raise NoSuchReactor: If no reactor is found with a matching C{shortName}.

@raise: anything that the specified reactor can raise when installed.
"""
for installer in getReactorTypes():
if installer.shortName == shortName:
installer.install()
from twisted.internet import reactor
return reactor
raise NoSuchReactor(shortName)