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

Unified Diff: third_party/twisted_8_1/twisted/internet/threads.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
Index: third_party/twisted_8_1/twisted/internet/threads.py
diff --git a/third_party/twisted_8_1/twisted/internet/threads.py b/third_party/twisted_8_1/twisted/internet/threads.py
deleted file mode 100644
index 415b66dca92a981fd379d112074c917153e12b18..0000000000000000000000000000000000000000
--- a/third_party/twisted_8_1/twisted/internet/threads.py
+++ /dev/null
@@ -1,88 +0,0 @@
-# Copyright (c) 2001-2007 Twisted Matrix Laboratories.
-# See LICENSE for details.
-
-"""
-Extended thread dispatching support.
-
-For basic support see reactor threading API docs.
-
-Maintainer: U{Itamar Shtull-Trauring<mailto:twisted@itamarst.org>}
-"""
-
-import Queue
-
-from twisted.python import failure
-from twisted.internet import defer
-
-
-def _putResultInDeferred(deferred, f, args, kwargs):
- """
- Run a function and give results to a Deferred.
- """
- from twisted.internet import reactor
- try:
- result = f(*args, **kwargs)
- except:
- f = failure.Failure()
- reactor.callFromThread(deferred.errback, f)
- else:
- reactor.callFromThread(deferred.callback, result)
-
-
-def deferToThread(f, *args, **kwargs):
- """
- Run function in thread and return result as Deferred.
- """
- d = defer.Deferred()
- from twisted.internet import reactor
- reactor.callInThread(_putResultInDeferred, d, f, args, kwargs)
- return d
-
-
-def _runMultiple(tupleList):
- """
- Run a list of functions.
- """
- for f, args, kwargs in tupleList:
- f(*args, **kwargs)
-
-
-def callMultipleInThread(tupleList):
- """
- Run a list of functions in the same thread.
-
- tupleList should be a list of (function, argsList, kwargsDict) tuples.
- """
- from twisted.internet import reactor
- reactor.callInThread(_runMultiple, tupleList)
-
-
-def blockingCallFromThread(reactor, f, *a, **kw):
- """
- Run a function in the reactor from a thread, and wait for the result
- synchronously, i.e. until the callback chain returned by the function
- get a result.
-
- @param reactor: The L{IReactorThreads} provider which will be used to
- schedule the function call.
- @param f: the callable to run in the reactor thread
- @type f: any callable.
- @param a: the arguments to pass to C{f}.
- @param kw: the keyword arguments to pass to C{f}.
-
- @return: the result of the callback chain.
- @raise: any error raised during the callback chain.
- """
- queue = Queue.Queue()
- def _callFromThread():
- result = defer.maybeDeferred(f, *a, **kw)
- result.addBoth(queue.put)
- reactor.callFromThread(_callFromThread)
- result = queue.get()
- if isinstance(result, failure.Failure):
- result.raiseException()
- return result
-
-
-__all__ = ["deferToThread", "callMultipleInThread", "blockingCallFromThread"]
-
« no previous file with comments | « third_party/twisted_8_1/twisted/internet/test/test_iocp.py ('k') | third_party/twisted_8_1/twisted/internet/tksupport.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698