473,395 Members | 1,456 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Threads for a newbe

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
1 1636
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Ronan Viernes | last post by:
Hi, I have created a python script (see below) to count the maximum number of threads per process (by starting new threads continuously until it breaks). ###### #testThread.py import...
1
by: Ron | last post by:
Is this built into any of the python versions? Need it! Using 2.3.5 and doesn't seem to have it.Newbe needs help!email ron@nac.net Thanks Ron
7
by: Jean Pierre Daviau | last post by:
Hi, <script language="javascript" type="text/javascript"> if(navigator.appName.indexOf("Netscape") != -1){ document.writeln('<link rel="stylesheet" href="~styles/aquarelle_ns.css"...
9
by: Yaro | last post by:
Hello DB2/NT 8.1.3 Sorry for stupid questions. I am newbe in DB2. 1. How can I read *.sql script (with table and function definitions) into a database? Tool, command... 2. In Project Center...
1
by: Jim | last post by:
I have created a windows form that contains several tab pages which contain a panels. On a tab page I am trying to dynamically create a series of buttons in that pages panel. I am failing because...
10
by: Darian | last post by:
Is there a way to find all the thread names that are running in a project? For example, if I have 5 threads T1, T2, T3, T4, T5...and T2, T4, and T5 are running...I want to be able to know that...
17
by: Eric_Dexter | last post by:
def simplecsdtoorc(filename): file = open(filename,"r") alllines = file.read_until("</CsInstruments>") pattern1 = re.compile("</") orcfilename = filename + "orc" for line in alllines: if not...
1
by: stan | last post by:
I am a complete newbe to python and only got here because I am trying to set up iTunes in game Second Life. Have followed all instructions but keep getting an error reading from my XP Pro OS as...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.