~justin-fathomdb/nova/justinsb-openstack-api-volumes

« back to all changes in this revision

Viewing changes to vendor/Twisted-10.0.0/twisted/internet/glib2reactor.py

  • Committer: Jesse Andrews
  • Date: 2010-05-28 06:05:26 UTC
  • Revision ID: git-v1:bf6e6e718cdc7488e2da87b21e258ccc065fe499
initial commit

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
 
 
2
"""
 
3
This module provides support for Twisted to interact with the glib mainloop.
 
4
This is like gtk2, but slightly faster and does not require a working
 
5
$DISPLAY. However, you cannot run GUIs under this reactor: for that you must
 
6
use the gtk2reactor instead.
 
7
 
 
8
In order to use this support, simply do the following::
 
9
 
 
10
    |  from twisted.internet import glib2reactor
 
11
    |  glib2reactor.install()
 
12
 
 
13
Then use twisted.internet APIs as usual.  The other methods here are not
 
14
intended to be called directly.
 
15
 
 
16
When installing the reactor, you can choose whether to use the glib
 
17
event loop or the GTK+ event loop which is based on it but adds GUI
 
18
integration.
 
19
 
 
20
Maintainer: Itamar Shtull-Trauring
 
21
"""
 
22
 
 
23
from twisted.internet import gtk2reactor
 
24
 
 
25
 
 
26
 
 
27
class Glib2Reactor(gtk2reactor.Gtk2Reactor):
 
28
    """
 
29
    The reactor using the glib mainloop.
 
30
    """
 
31
 
 
32
    def __init__(self):
 
33
        """
 
34
        Override init to set the C{useGtk} flag.
 
35
        """
 
36
        gtk2reactor.Gtk2Reactor.__init__(self, useGtk=False)
 
37
 
 
38
 
 
39
 
 
40
def install():
 
41
    """
 
42
    Configure the twisted mainloop to be run inside the glib mainloop.
 
43
    """
 
44
    reactor = Glib2Reactor()
 
45
    from twisted.internet.main import installReactor
 
46
    installReactor(reactor)
 
47
    
 
48
__all__ = ['install']
 
49