Initial import to Tizen
[profile/ivi/python-twisted.git] / twisted / internet / main.py
1 # -*- test-case-name: twisted.internet.test.test_main -*-
2 # Copyright (c) Twisted Matrix Laboratories.
3 # See LICENSE for details.
4
5
6 """
7 Backwards compatibility, and utility functions.
8
9 In general, this module should not be used, other than by reactor authors
10 who need to use the 'installReactor' method.
11
12 Maintainer: Itamar Shtull-Trauring
13 """
14
15 import error
16
17 CONNECTION_DONE = error.ConnectionDone('Connection done')
18 CONNECTION_LOST = error.ConnectionLost('Connection lost')
19
20 def installReactor(reactor):
21     """
22     Install reactor C{reactor}.
23
24     @param reactor: An object that provides one or more IReactor* interfaces.
25     """
26     # this stuff should be common to all reactors.
27     import twisted.internet
28     import sys
29     if 'twisted.internet.reactor' in sys.modules:
30         raise error.ReactorAlreadyInstalledError("reactor already installed")
31     twisted.internet.reactor = reactor
32     sys.modules['twisted.internet.reactor'] = reactor
33
34
35 __all__ = ["CONNECTION_LOST", "CONNECTION_DONE", "installReactor"]