473,569 Members | 2,590 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.threadse rver = threading.Threa d(target = self.__startser ver)
then do while 1 :
socket, host = accept(...)
then start a new thread for each new connexion after accept using client.threadcl ient = threading.Threa d(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 1649
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.threadse rver =
threading.Threa d(target = self.__startser ver) then do while 1 :
socket, host = accept(...)
then start a new thread for each new connexion after accept using
client.threadcl ient = threading.Threa d(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
5382
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 thread, sys
1
1771
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
1879
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" type="text/css" media="screen" title="base" />'); }else{ document.write('<link rel="stylesheet" href="~styles/aquarelle.css" type="text/css" media="screen"...
9
6669
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 I created funcion CREATE FUNCTION DB2ADMIN.xxx( )
1
2007
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 I can not find the proper way to point to the specific tab page and its panel when creating the buttons. I also need to dynamically change the...
10
1744
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 T2, T4 and T5 are already running. Thanks, Darian
17
2692
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 pattern1 print >>orcfilename, line I am pretty sure my code isn't close to what I want. I need to be able
1
1191
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 follows File "C:\Python24\2L file for iTunes", line 4, in -toplevel- import win32com.client ImportError: No module named win32com.client can...
0
7615
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7924
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8130
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7677
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7979
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6284
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5514
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3643
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1223
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.