By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,652 Members | 1,317 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,652 IT Pros & Developers. It's quick & easy.

Threads for a newbe

P: n/a
Hello,
First let say that am french and that i'll try to write the best english i can...
I'm a python newbe and have the following problem : I try to create 2 threads in a server program and they seems to block each other.
I use something like this :
start thread waiting for connexion with : server.threadserver = threading.Thread(target = self.__startserver)
then do while 1 :
socket, host = accept(...)
then start a new thread for each new connexion after accept using client.threadclient = threading.Thread(target = self.__receive)
and while 1 :
client.receive()
And here the first thread seems not to work anymore :( . I didn't join threads. Maybe a lock() problem but i don't now how to use the lock() function in Python...
Maybe if someone had a multithread server sample source I could understand what is the issue...
Regards
Seb.
Jul 18 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Hi,
i can... I'm a python newbe and have the following problem : I try to
create 2 threads in a server program and they seems to block each other.
I use something like this :
start thread waiting for connexion with : server.threadserver =
threading.Thread(target = self.__startserver) then do while 1 :
socket, host = accept(...)
then start a new thread for each new connexion after accept using
client.threadclient = threading.Thread(target = self.__receive)
and while 1 :
client.receive()
And here the first thread seems not to work anymore :( . I didn't join
threads. Maybe a lock() problem but i don't now how to use the lock()
function in Python... Maybe if someone had a multithread server sample
source I could understand what is the issue...


I recently did implement a socket-server using threads. So if you give me
more actual code, I might be able to help you.

However, I stepped away from that approach and went for twisted - a really
excellent networing framework, which eliminated the need for different
threads. You should really look into that, as just having different threads
sitting on blocking io-descriptors is abusing them (while I have to admit -
its tempting...)

Regards,

Diez
Jul 18 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.