[Tutor] Async Events (or How to manage interrupts in Python?)

Alan Gauld alan.gauld at blueyonder.co.uk
Mon Dec 29 16:56:25 EST 2003


> First, let me tell you what all this is about. I have a very nice
script
> that does the following:
> 1. It checks if there is a file in an Open VMS server.
> 2. If it finds the file, it connects via TELNET (using telnetlib, of
> course!) and ZIP's it.
> 3. Once the file is compressed, it GET's it via FTP (using ftplib)
> 4. When the file is in my local machine, the script does some
processing
> on it.
> 5. If the script was given more than one file to look at the VMS
server
> it goes back to Step 1.
>
> Quite simple, right?
> The thing is that I don't want this to perform sequentially...
> it's such a waste of time!

Quite right, look at the thread module, it's for allowing
parallel threads of execution. Write the bit that can be
done in parallel as a function - making sure to avoid using
any global variables! - and call that function in a new
thread. See the thread module documentation for that.

Alan G
Author of the Learn to Program web tutor
http://www.freenetpages.co.uk/hp/alan.gauld




More information about the Tutor mailing list