Trees | Indices | Help |
|
---|
|
1 # This file is part of Buildbot. Buildbot is free software: you can 2 # redistribute it and/or modify it under the terms of the GNU General Public 3 # License as published by the Free Software Foundation, version 2. 4 # 5 # This program is distributed in the hope that it will be useful, but WITHOUT 6 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 7 # FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 8 # details. 9 # 10 # You should have received a copy of the GNU General Public License along with 11 # this program; if not, write to the Free Software Foundation, Inc., 51 12 # Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 13 # 14 # Copyright Buildbot Team Members 15 16 17 # copied from foolscap 18 19 from twisted.internet import reactor, defer 20 from twisted.python import log 2123 24 _reactor = reactor 25 3163 64 65 _theSimpleQueue = _SimpleCallQueue() 66 69 70 7533 self._events.append((cb, args, kwargs)) 34 if not self._timer: 35 self._timer = self._reactor.callLater(0, self._turn)3638 self._timer = None 39 self._in_turn = True 40 # flush all the messages that are currently in the queue. If anything 41 # gets added to the queue while we're doing this, those events will 42 # be put off until the next turn. 43 events, self._events = self._events, [] 44 for cb, args, kwargs in events: 45 try: 46 cb(*args, **kwargs) 47 except: 48 log.err() 49 self._in_turn = False 50 if self._events and not self._timer: 51 self._timer = self._reactor.callLater(0, self._turn) 52 if not self._events: 53 observers, self._flushObservers = self._flushObservers, [] 54 for o in observers: 55 o.callback(None)5658 if not self._events and not self._in_turn: 59 return defer.succeed(None) 60 d = defer.Deferred() 61 self._flushObservers.append(d) 62 return d77 return _theSimpleQueue.flush()7880 # This sets the reactor used to schedule future events to r. If r is None 81 # (the default), the reactor is reset to its default value. 82 # This should only be used for unit tests. 83 if r is None: 84 r = reactor 85 _theSimpleQueue._reactor = r86
Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0.1 on Wed Nov 21 16:23:04 2012 | http://epydoc.sourceforge.net |