Re: Doubt on creating threads
On Jan 4, 4:59 am, Bryan Olson wrote: > koranth...@gmail.com wrote: > > 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? > > Compared to a procedure call it's expensive, but a couple threads per > second is insignificant. My out-dated Pentium 4 desktop can create and > destroy a few thousand threads per second under WinXP; more under recent > Linux. > > -- > --Bryan Thank you very much. I was worried about this a lot. -- http://mail.python.org/mailman/listinfo/python-list
Re: Doubt on creating threads
koranth...@gmail.com wrote: 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? Compared to a procedure call it's expensive, but a couple threads per second is insignificant. My out-dated Pentium 4 desktop can create and destroy a few thousand threads per second under WinXP; more under recent Linux. -- --Bryan -- http://mail.python.org/mailman/listinfo/python-list
Re: Doubt on creating threads
On Jan 3, 8:39 am, koranth...@gmail.com wrote: > I was going through Python posts and this post caught my > attentionhttp://groups.google.com/group/comp.lang.python/browse_thread/thread/... > > > 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. > > > 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). Generally you should only worry about this sort of thing if A) you actually notice a performance problem and B) testing indicates that it's thread creation which is causing it. Otherwise you could spend a lot of time working on something that doesn't actually affect your app's performance. ~S -- http://mail.python.org/mailman/listinfo/python-list
Re: Doubt on creating threads
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 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. 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
Doubt on creating threads
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 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. 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). -- http://mail.python.org/mailman/listinfo/python-list