On 11-09-04 05:31 PM, Michael Hudson-Doyle wrote: > On Thu, 01 Sep 2011 17:46:53 -0400, "Francis J. Lacoste" > <[email protected]> wrote: > Non-text part: multipart/signed
>> We don't explicitely configure a thread pool either. So it's either
>> unbounded or using twisted default settings. And looking at
>> deferToThread it seems that as many threads as required will be created:
>>
>> def deferToThread(f):
>> """Run the given callable in a separate thread and return a Deferred
>> which
>> fires when the function completes.
>> """
>> def decorated(*args, **kwargs):
>> d = defer.Deferred()
>> def runInThread():
>> return threads._putResultInDeferred(d, f, args, kwargs)
>>
>> t = threading.Thread(target=runInThread)
>> t.start()
>> return d
>> return mergeFunctionMetadata(f, decorated)
>
> Where did you find that deferToThread[1]? AFAICT, this is the one used
> by the librarian (from
> eggs/Twisted-11.0.0-py2.6-linux-x86_64.egg/twisted/internet/threads.py):
I pasted the first definition that 'tags' found. Didn't thought of
checking if it was the correct one :-) That one comes from
lp/codehosting/tests/helpers.py line 113
>
> def deferToThread(f, *args, **kwargs):
> """
> Run a function in a thread and return the result as a Deferred.
>
> @param f: The function to call.
> @param *args: positional arguments to pass to f.
> @param **kwargs: keyword arguments to pass to f.
>
> @return: A Deferred which fires a callback with the result of f,
> or an errback with a L{twisted.python.failure.Failure} if f throws
> an exception.
> """
> from twisted.internet import reactor
> return deferToThreadPool(reactor, reactor.getThreadPool(),
> f, *args, **kwargs)
>
> So, we're using the default thread pool, and that seems to be configured
> to use a maximum of 10 threads:
>
> def _initThreadPool(self):
> """
> Create the threadpool accessible with callFromThread.
> """
> from twisted.python import threadpool
> self.threadpool = threadpool.ThreadPool(
> 0, 10, 'twisted.internet.reactor')
>
That's much more comforting! Thanks.
--
Francis J. Lacoste
[email protected]
signature.asc
Description: OpenPGP digital signature
_______________________________________________ Mailing list: https://launchpad.net/~launchpad-dev Post to : [email protected] Unsubscribe : https://launchpad.net/~launchpad-dev More help : https://help.launchpad.net/ListHelp

