Managing timing in Python calls

Ross nospam at forMe.thks
Mon Dec 15 16:21:03 CET 2008

I'm porting some ugly javascript managed stuff to have an equivalent 
behaviour in a standalone app. It uses events that arrive from a server, 
and various small images.  In this standalone version, the data is local 
in a file and the images in a local directory.

My AJAX code managed a timely presentation of the info, and in the 
Javascript that relied on the ugly:

	myImage.onload = function(){dosomething_when_it's_finished}

structure. Also, I used the similarly unpretty:

	var t = window.setTimeout( function () { do_when_timed_out}

structures which allows stuff to happen after a perscribed period.

In my python implementation my first guess is to use a thread to load my 
image into a variable

      myImage = wx.Image("aPic.gif",
		wx.BITMAP_TYPE_GIF ).ConvertToBitmap()

so that it won't block processing. (Though perhaps it'll just happen so 
fast without a server involved that I won't care.)

Is there a nice equivalent of a 'setTimeout' function in python? ie to 
call a function after some time elapses without blocking my other 
processing?  I suppose just a thread with a time.sleep(x_mS) in it would 
be my first guess?

Can anyone give me some feedback on whether that's a logical path 
forward, or if there are some nicer constructs into which I might look?

Thanks for any suggests... Ross.

More information about the Python-list mailing list