~ssweeny/friends/fix-lp1258657

« back to all changes in this revision

Viewing changes to friends/main.py

  • Committer: Andrew Starr-Bochicchio
  • Date: 2013-04-16 17:51:32 UTC
  • mfrom: (160.11.29 trunk-next)
  • mto: This revision was merged to the branch mainline in revision 218.
  • Revision ID: a.starr.b@gmail.com-20130416175132-kurn5v12qr2rhfn1
Merge on lp:~super-friends/friends/trunk-next

Show diffs side-by-side

added added

removed removed

Lines of Context:
36
36
DBusGMainLoop(set_as_default=True)
37
37
loop = GLib.MainLoop()
38
38
 
 
39
from friends.errors import ignored
39
40
 
40
41
# Short-circuit everything else if we are going to enter test-mode.
41
42
from friends.utils.options import Options
48
49
    populate_fake_data()
49
50
    Dispatcher()
50
51
 
51
 
    try:
 
52
    with ignored(KeyboardInterrupt):
52
53
        loop.run()
53
 
    except KeyboardInterrupt:
54
 
        pass
55
54
 
56
55
    sys.exit(0)
57
56
 
102
101
        sys.exit('friends-dispatcher is already running! Abort!')
103
102
 
104
103
    if args.performance:
105
 
        try:
 
104
        with ignored(ImportError):
106
105
            import yappi
107
 
        except ImportError:
108
 
            pass
109
 
        else:
110
106
            yappi.start()
111
107
 
112
108
    # Initialize the logging subsystem.
138
134
    # Don't initialize caches until the model is synchronized
139
135
    Model.connect('notify::synchronized', setup)
140
136
 
141
 
    try:
 
137
    with ignored(KeyboardInterrupt):
142
138
        log.info('Starting friends-dispatcher main loop')
143
139
        loop.run()
144
 
    except KeyboardInterrupt:
145
 
        pass
146
140
 
147
141
    log.info('Stopped friends-dispatcher main loop')
148
142
 
167
161
    # data for the purposes of faster duplicate checks.
168
162
    initialize_caches()
169
163
 
170
 
    # Allow publishing.
171
 
    try:
 
164
    # Exception indicates that lock was already released, which is harmless.
 
165
    with ignored(RuntimeError):
 
166
        # Allow publishing.
172
167
        _publish_lock.release()
173
 
    except RuntimeError:
174
 
        # Happens if the lock was already released previously, which
175
 
        # is safe to ignore. Dispatcher goes on to publish normally.
176
 
        pass
177
168
 
178
169
 
179
170
if __name__ == '__main__':