MultiThread Socket on NT

Werner Schiendl ws-news at gmx.at
Fri Nov 16 11:59:12 CET 2001


Hi,

did you notice, that the SocketServer module contains a ready-made socket
server?
It even includes a threaded server (2 in fact, ThreadingTCPServer and
ThreadingUDPServer).

Your problem with performance could come from creating a new thread for
every request.
Depending on the OS, creating threads may be an expensive operation.
(e. g. Windows calls the DllMain() function in all loaded DLLs, unless they
explicitely specified they do not want this)

To have a better scalable solution, you could use a thread pool.

hth
Werner

"GT" <guy.theisen at isp.lu> wrote in message
news:e253b770.0111152322.7a1933c5 at posting.google.com...
> Hi,
>
>   I have a Simple Thread Socket Server. But if I lunch the Socket Server,
and
>   many clients connect to this server, I must wait a long time for an
answer.
>   I use in this case a simple Thread.
>
>   while 1:
>         conn, addr = s.accept()
>         if fail:
>             thread = threading.Thread(target=burp, args=(conn,addr))
>             thread.start()
>         else:
>             burp(conn,addr)
>
>  But how can I set up a multithread Socket ?
>
>
> Thanks for any help,
>
> GT





More information about the Python-list mailing list