Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!news.swapon.de!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Marko Rauhamaa Newsgroups: comp.lang.python Subject: Re: Thread terminate Date: Thu, 28 Aug 2014 12:02:29 +0300 Organization: A noiseless patient Spider Lines: 17 Message-ID: <87sikhf0m2.fsf@elektro.pacujo.net> References: <20140827185514.GA18660@arxnet.hu> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Info: mx05.eternal-september.org; posting-host="ff5cf27ef3d5b31f034d3b72bdc27a41"; logging-data="31671"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+TkVjd7bFHHl+b3w8c6msa" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.3 (gnu/linux) Cancel-Lock: sha1:fv0X7nY8vs0TQNnHP85P1WUQ850= sha1:XcLAOrXwcUHUxdTcUF9lPy1XbeU= Xref: csiph.com comp.lang.python:77192 Ervin Hegedüs : > at this time there is only one thread, as you wrote. I just try > to prepare it to higher load, when one thread will not enough... Threads are a necessary evil when dealing with blocking function calls, but evil they remain. I would generally *not* associate a thread for each parallel context but work with a limited thread pool, whose size is independent of the number of contexts. Often, a good rule of thumb is to have two threads per CPU core to get most out of the hardware. Since you talked about forking, you might be better served with a pool of processes instead of threads since processes have less surprising semantics and, if push came to shove, you can kill them with a signal. Marko