Keith F Irwin
kirwin14 at home.com
Sat Jul 14 13:55:11 EDT 2001
Could you use threads? I just wrote a program that does something like:
1. start thread to read database between sleep(500)
2. start thread to ping machines listed in database, update global
3. in forever loop, listen on a socket, if there's a connection, start
thread to handle it (ie, spit out html table of global struct, close
Not sure if this fits in, but using timed threads can get you out of the
event driven model. So, have a thread to listen via socket and update
list when data comes in, another thread to print out list when list
changes. You'll have to lock the list while it's being update, which'll
make the list print method wait until it's updated. Add some sleeps to
slow things down a bit, etc.
Anyway, I'm new to python, and new to socket stuff too, so....
On 14 Jul 2001 13:18:31 -0400, Shane Anglin wrote:
> Here's the basics of what I want to do with my new app:
> Main loop is:
> 1 - check socket for any incoming data
> 1a - if no data on socket, go to 2, else get the data and place it into a list
> 2 - print out list
> 3 - go to 1 and do it all over again
> Currently, I can create a TCP socket server app using examples that will sit and wait (idle 99% of the time) and accepts the incoming data just fine, my 'print list' part is not processing at all until I get any new data in... for example, 1-wait on a client connect on socket, when a connection happens, get data, 2- place new data into list, print list, 3 -go to 1 and do it all over again... in this scenario, #1 has the rest of my code 'hostage' until a client connection is made and closed.
> Thanks a bunch!
> Shane Anglin
> shaneanglin at bigfoot.com
More information about the Python-list