On Sat, 3 Jan 2009 08:39:52 -0800 (PST), koranth...@gmail.com wrote:
I was going through Python posts and this post caught my attention
http://groups.google.com/group/comp.lang.python/browse_thread/thread/f99326a4e5d394e/14cd708956bd1c1a#14cd708956bd1c1a

<quote>
You have missed an important point. A well designed application does
neither create so many threads nor processes. The creation of a
thread
or forking of a process is an expensive operation. You should use a
pool
of threads or processes.
</unquote>

I am creating an application and it creates ~1-2 threads every second
and kill it within 10 seconds. After reading this I am worried. Is
creating a thread a very costly operation? I cannot use a pool of
threads because I am using an external application (twisted) to create
the threads (deferToThread).

Actually, deferToThread is implemented in terms of a thread pool.  So
you're only creating a small number of threads, and then they're being
re-used.

I somewhat disagree with the assertion that not using a threadpool means
that your application is "well designed".  However, it's absolutely true
that using a threadpool lowers the runtime cost of using threads compared
to creating and destroying threads all the time.

Jean-Paul
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to