Multiple Threads & IRC

Wilbur willybur at
Sun Dec 10 18:46:40 EST 2000

I am pretty new to Python, but am starting to get the hang of it.

Just to see if I can do it, I'm trying to write an IRC client, using Tk 
and Python.  However, I've run up against a few problems.

It seems that I will need multiple threads running for this client.  One 
thread will have to be constantly checking my socket to see if the 
server has sent anything.  The other thread will deal with the user 
side, so he can input information.  The documentation on threads is very 
sparse; can someone briefly summarize how to use more than one thread in 
a program, especially when the threads must be maintained, must loop, 
need more than one line of code, and must all be able to send and 
receive data?

I'm going to need to use sockets.  I have, by taking bits and pieces 
from examples, been able to successfully connect to an IRC server, and 
receive a bit of data.
Here's the problem:
The server sends data in packets, and it sends whenever it can.  How can 
I get my client to be able to receive data from the server without 
knowing when it will send and what amount of data will be sent?  I only 
know how to tell Python to wait until it receives, say, 1024 bytes.  If 
the server doesn't send any more, how can I tell Python to stop waiting? 
  This is where I have come to the conclusion that I need to run this 
part in the background, while the rest of the program is running.  If 
Python can't run such tasks simultaneously, would I need to have Python 
just run a whole other program?  One would do the port listening and 
sending, and one would interface with the user.  The second program 
would command the first program around.

Thanks in advance,

More information about the Python-list mailing list