Python twisted.internet.threads.callMultipleInThread() Examples

The following are 4 code examples of twisted.internet.threads.callMultipleInThread(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module twisted.internet.threads , or try the search function .
Example #1
Source File: test_threads.py    From Safejumper-for-Desktop with GNU General Public License v2.0 6 votes vote down vote up
def test_callMultiple(self):
        """
        L{threads.callMultipleInThread} calls multiple functions in a thread.
        """
        L = []
        N = 10
        d = defer.Deferred()

        def finished():
            self.assertEqual(L, list(range(N)))
            d.callback(None)

        threads.callMultipleInThread([
            (L.append, (i,), {}) for i in xrange(N)
            ] + [(reactor.callFromThread, (finished,), {})])
        return d 
Example #2
Source File: test_threads.py    From learn_python3_spider with MIT License 6 votes vote down vote up
def test_callMultiple(self):
        """
        L{threads.callMultipleInThread} calls multiple functions in a thread.
        """
        L = []
        N = 10
        d = defer.Deferred()

        def finished():
            self.assertEqual(L, list(range(N)))
            d.callback(None)

        threads.callMultipleInThread([
            (L.append, (i,), {}) for i in range(N)
            ] + [(reactor.callFromThread, (finished,), {})])
        return d 
Example #3
Source File: test_threads.py    From python-for-android with Apache License 2.0 5 votes vote down vote up
def testCallMultiple(self):
        L = []
        N = 10
        d = defer.Deferred()

        def finished():
            self.assertEquals(L, range(N))
            d.callback(None)

        threads.callMultipleInThread([
            (L.append, (i,), {}) for i in xrange(N)
            ] + [(reactor.callFromThread, (finished,), {})])
        return d 
Example #4
Source File: test_threads.py    From BitTorrent with GNU General Public License v3.0 5 votes vote down vote up
def testCallMultiple(self):
        L = []
        N = 10
        d = defer.Deferred()

        def finished():
            self.assertEquals(L, range(N))
            d.callback(None)

        threads.callMultipleInThread([
            (L.append, (i,), {}) for i in xrange(N)
            ] + [(reactor.callFromThread, (finished,), {})])
        return d