"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "buildbot/test/fake/reactor.py" between
buildbot-2.0.0.tar.gz and buildbot-2.0.1.tar.gz

About: Buildbot is a continuous integration testing framework (Python-based). It supports also automation of complex build systems, application deployment, and management of sophisticated software-release processes.

reactor.py  (buildbot-2.0.0):reactor.py  (buildbot-2.0.1)
skipping to change at line 23 skipping to change at line 23
# included in all copies or substantial portions of the Software. # included in all copies or substantial portions of the Software.
# #
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
from twisted.internet import defer
from twisted.internet import reactor from twisted.internet import reactor
from twisted.internet.base import _ThreePhaseEvent from twisted.internet.base import _ThreePhaseEvent
from twisted.internet.interfaces import IReactorCore from twisted.internet.interfaces import IReactorCore
from twisted.internet.interfaces import IReactorThreads from twisted.internet.interfaces import IReactorThreads
from twisted.internet.task import Clock from twisted.internet.task import Clock
from twisted.python import log
from twisted.python.failure import Failure from twisted.python.failure import Failure
from zope.interface import implementer from zope.interface import implementer
# The code here is based on the implementations in # The code here is based on the implementations in
# https://twistedmatrix.com/trac/ticket/8295 # https://twistedmatrix.com/trac/ticket/8295
# https://twistedmatrix.com/trac/ticket/8296 # https://twistedmatrix.com/trac/ticket/8296
@implementer(IReactorCore) @implementer(IReactorCore)
class CoreReactor(object): class CoreReactor(object):
skipping to change at line 130 skipping to change at line 132
def _executeCurrentDelayedCalls(self): def _executeCurrentDelayedCalls(self):
while self.getDelayedCalls(): while self.getDelayedCalls():
first = sorted(self.getDelayedCalls(), first = sorted(self.getDelayedCalls(),
key=lambda a: a.getTime())[0] key=lambda a: a.getTime())[0]
if first.getTime() > self.seconds(): if first.getTime() > self.seconds():
break break
self.advance(0) self.advance(0)
self._pendingCurrentCalls = False self._pendingCurrentCalls = False
@defer.inlineCallbacks
def _catchPrintExceptions(self, what, *a, **kw):
try:
r = what(*a, **kw)
if isinstance(r, defer.Deferred):
yield r
except Exception as e:
log.msg('Unhandled exception from deferred when doing '
'TestReactor.advance()', e)
raise
def callLater(self, when, what, *a, **kw): def callLater(self, when, what, *a, **kw):
# Buildbot often uses callLater(0, ...) to defer execution of certain # Buildbot often uses callLater(0, ...) to defer execution of certain
# code to the next iteration of the reactor. This means that often # code to the next iteration of the reactor. This means that often
# there are pending callbacks registered to the reactor that might # there are pending callbacks registered to the reactor that might
# block other code from proceeding unless the test reactor has an # block other code from proceeding unless the test reactor has an
# iteration. To avoid deadlocks in tests we give the real reactor a # iteration. To avoid deadlocks in tests we give the real reactor a
# chance to advance the test reactor whenever we detect that there # chance to advance the test reactor whenever we detect that there
# are callbacks that should run in the next iteration of the test # are callbacks that should run in the next iteration of the test
# reactor. # reactor.
#
# Additionally, we wrap all calls with a function that prints any
# unhandled exceptions
if when <= 0 and not self._pendingCurrentCalls: if when <= 0 and not self._pendingCurrentCalls:
reactor.callLater(0, self._executeCurrentDelayedCalls) reactor.callLater(0, self._executeCurrentDelayedCalls)
return Clock.callLater(self, when, what, *a, **kw) return Clock.callLater(self, when, self._catchPrintExceptions,
what, *a, **kw)
def stop(self): def stop(self):
# first fire pending calls until the current time. Note that the real # first fire pending calls until the current time. Note that the real
# reactor only advances until the current time in the case of shutdown. # reactor only advances until the current time in the case of shutdown.
self.advance(0) self.advance(0)
# then, fire the shutdown event # then, fire the shutdown event
self.fireSystemEvent('shutdown') self.fireSystemEvent('shutdown')
 End of changes. 5 change blocks. 
1 lines changed or deleted 18 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)