Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Re: Threading question

Reply
Thread Tools

Re: Threading question

 
 
JosÚ Carlos
Guest
Posts: n/a
 
      02-01-2004
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.


----- Original Message -----
From: "Rene Pijlman" <(E-Mail Removed)>
Newsgroups: comp.lang.python
Sent: Sunday, February 01, 2004 11:09 PM
Subject: Re: Threading question


> JosÚ Carlos:
> >How can i do for create a list which it obtain the name or number of

client
> >when it is trying to connect with server. i want obtain this list for

use
> >it with threading

>
> I don't understand this question. How should who get a list of what from
> where, and why is this related to threading?
>
> --
> RenÚ Pijlman






 
Reply With Quote
 
 
 
 
Jeff Epler
Guest
Posts: n/a
 
      02-01-2004
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

 
Reply With Quote
 
 
 
 
Cameron Laird
Guest
Posts: n/a
 
      02-02-2004
In article <(E-Mail Removed)>,
Jeff Epler <(E-Mail Removed)> 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 <(E-Mail Removed)>
Business: http://www.Phaseit.net
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: threading in PyQt vs threading in standard library Steven Woody Python 0 01-09-2009 07:48 AM
threading in PyQt vs threading in standard library Steven Woody Python 0 01-09-2009 07:15 AM
Cooperative threading preemptive threading - a bit confused failure_to@yahoo.co.uk Java 9 12-29-2007 01:10 AM
Threading question Frederick Wilson Firefox 1 12-22-2004 12:23 AM
disconnected DataSet multi-threading question Alina ASP .Net 0 07-16-2003 04:23 PM



Advertisments