~lutostag/ubuntu/utopic/maas/1.5.2+packagefix

« back to all changes in this revision

Viewing changes to src/maasserver/eventloop.py

  • Committer: Package Import Robot
  • Author(s): Andres Rodriguez, Graham Binns, Andres Rodriguez, Julian Edwards, Seth Arnold
  • Date: 2014-02-15 12:08:23 UTC
  • mfrom: (1.2.22)
  • Revision ID: package-import@ubuntu.com-20140215120823-kew2lqrw5qgww721
Tags: 1.5+bzr1948-0ubuntu1
* New upstream release.

[ Graham Binns ]
* debian/control: Depends on python-jsonschema.

[ Andres Rodriguez ]
* debian/maas-region-controller-min.posinst: Make txlongpoll.yaml only
  readable by the app and not world readeable.
* debian/patches/02-pserv-config.patch: Refreshed.

[ Julian Edwards ]
* debian/extras/maas-cli renamed to debian/extras/maas, and introduce
  a deprecation warning in favour of using maas over maas-cli.
* debian/extras/maas renamed to debian/extras/maas-region-admin
* debian/maas-cli.install: install debian/extras/maas
* debian/maas-dns.postinst: Invoke maas-region-admin instead of maas
* debian/maas-region-controller-min.install: install maas-region-admin
  instead of maas
* debian/maas-region-controller.postinst: Invoke maas-region-admin instead
  of maas
* debian/maas-cli.links: Link from maas to maas-cli for backward compat.

[ Seth Arnold ]
* debian/maas-region-controller-min.postinst: Make sure txlongpoll.yaml
  gets correct permissions on upgrade (LP: #1254034)

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
 
19
19
__metaclass__ = type
20
20
__all__ = [
 
21
    "services",
21
22
    "start",
22
23
    "stop",
23
24
]
25
26
from functools import wraps
26
27
from logging import getLogger
27
28
from os import getpid
 
29
from socket import gethostname
28
30
 
29
31
import crochet
30
32
from django.utils import autoreload
60
62
 
61
63
 
62
64
class RegionEventLoop:
 
65
    """An event loop running in a region controller process.
 
66
 
 
67
    Typically several processes will be running the web application -
 
68
    chiefly Django - across several machines, with multiple threads of
 
69
    execution in each process.
 
70
 
 
71
    This class represents a single event loop for each *process*,
 
72
    allowing convenient control of the event loop - a Twisted reactor
 
73
    running in a thread - and to which to attach and query services.
 
74
    """
63
75
 
64
76
    def __init__(self):
65
77
        super(RegionEventLoop, self).__init__()
68
80
 
69
81
    def init(self):
70
82
        """Spin up a Twisted event loop in this process."""
71
 
        if crochet.reactor.running:
72
 
            return  # This should only be called once.
73
 
        else:
 
83
        if not crochet.reactor.running:
74
84
            logger.info("Starting event loop in process %d", getpid())
75
85
            crochet.setup()
76
86
 
94
104
            crochet.reactor.removeSystemEventTrigger(handle)
95
105
        return self.services.stopService()
96
106
 
 
107
    @property
 
108
    def name(self):
 
109
        """A name for identifying this service in a distributed system."""
 
110
        return "%s:pid=%d" % (gethostname(), getpid())
 
111
 
97
112
 
98
113
loop = RegionEventLoop()
 
114
services = loop.services
99
115
start = loop.start
100
116
stop = loop.stop
101
117