Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(242)

Unified Diff: third_party/twisted_8_1/twisted/flow/controller.py

Issue 12261012: Remove third_party/twisted_8_1 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/build
Patch Set: Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/twisted_8_1/twisted/flow/base.py ('k') | third_party/twisted_8_1/twisted/flow/flow.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/twisted_8_1/twisted/flow/controller.py
diff --git a/third_party/twisted_8_1/twisted/flow/controller.py b/third_party/twisted_8_1/twisted/flow/controller.py
deleted file mode 100644
index 303d51d3dc8421574e3f6c43bf0477ce8e71ae11..0000000000000000000000000000000000000000
--- a/third_party/twisted_8_1/twisted/flow/controller.py
+++ /dev/null
@@ -1,101 +0,0 @@
-# Copyright (c) 2001-2004 Twisted Matrix Laboratories.
-# See LICENSE for details.
-
-#
-# Author: Clark Evans (cce@clarkevans.com)
-#
-
-"""
-flow.controller
-
-This implements the various flow controllers, that is, those things which run
-the flow stack.
-"""
-
-from base import *
-from wrap import wrap
-from twisted.internet import defer
-
-class Block(Controller,Stage):
- """
- A controller which blocks on Cooperate events
-
- This converts a Stage into an iterable which can be used directly in python
- for loops and other iteratable constructs. It does this by eating any
- Cooperate values and sleeping. This is largely helpful for testing or
- within a threaded environment. It converts other stages into one which
- does not emit cooperate events, ie::
-
- [1,2, Cooperate(), 3] => [1,2,3]
- """
- def __init__(self, stage, *trap):
- Stage.__init__(self)
- self._stage = wrap(stage,*trap)
- self.block = time.sleep
-
- def next(self):
- """ fetch the next value from the Stage flow """
- stage = self._stage
- while True:
- result = stage._yield()
- if result:
- if isinstance(result, Cooperate):
- if result.__class__ == Cooperate:
- self.block(result.timeout)
- continue
- raise Unsupported(result)
- return stage.next()
-
-class Deferred(Controller, defer.Deferred):
- """
- wraps up a Stage with a Deferred interface
-
- In this version, the results of the Stage are used to construct a list of
- results and then sent to deferred. Further, in this version Cooperate is
- implemented via reactor's callLater.
-
- For example::
-
- from twisted.internet import reactor
- from twisted.flow import flow
-
- def res(x): print x
- d = flow.Deferred([1,2,3])
- d.addCallback(res)
- reactor.iterate()
- """
- def __init__(self, stage, *trap):
- defer.Deferred.__init__(self)
- self._results = []
- self._stage = wrap(stage, *trap)
- self._execute()
-
- def results(self, results):
- self._results.extend(results)
-
- def _execute(self, dummy = None):
- cmd = self._stage
- while True:
- result = cmd._yield()
- if cmd.results:
- self.results(cmd.results)
- cmd.results = []
- if cmd.stop:
- if not self.called:
- self.callback(self._results)
- return
- if cmd.failure:
- cmd.stop = True
- if cmd._trap:
- error = cmd.failure.check(*cmd._trap)
- if error:
- self._results.append(error)
- continue
- self.errback(cmd.failure)
- return
- if result:
- if isinstance(result, CallLater):
- result.callLater(self._execute)
- return
- raise Unsupported(result)
-
« no previous file with comments | « third_party/twisted_8_1/twisted/flow/base.py ('k') | third_party/twisted_8_1/twisted/flow/flow.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698