Threading question

Cameron Laird claird at lairds.com
Sun Feb 1 20:32:44 EST 2004


In article <mailman.1112.1075678446.12720.python-list at python.org>,
Jeff Epler  <jepler at unpythonic.net> wrote:
>On Sun, Feb 01, 2004 at 11:25:26PM +0100, Jos� Carlos wrote:
>> sorry.
>> 
>> I want assign a name to each thread.
>> 
>> I want when the server accept to client, the server add to  list the client
>> with a name, for example client1.
>> 
>> the name of thread will be the name assigned to each client.
>
>Use a dictionary.  Almost any object can be a dictionary key, and any
>object can be a dictionary value.
>
>Example:
>	class MyThread(threading.Thread): pass
>	clients = {}
>	client['client1'] = MyThread(...)
>
>Jeff
>

All true.

HOWEVER, please be aware that you do NOT have to assign
a separate thread to each client in order to construct a
server which can handle multiple concurrent clients.
Several different concurrency models are possible for
network service; among them, thread-per-client has 
particular performance and development constraints.  If
you're willing to program at a higher level of abstrac-
tion, asyncore and Twisted provide two excellent
alternatives for sound design of a server.
-- 

Cameron Laird <claird at phaseit.net>
Business:  http://www.Phaseit.net



More information about the Python-list mailing list