I'm writing a PyQt network client for XMMS, using the InetCtrl plugin, that on connection receives a track length.
To save on bandwidth, I don't want to be continually querying the server for updates (e.g. has the current track finished yet?) so I figured the best thing to do is just update after the track length has expired. So, how would I make a Python program automatically call a function after a preset period of time, without the Python process running in the foreground (effectively single-tasking)? I think that sleep() would work in the foreground (kind of like a while loop does, I've come across that issue with wxPython!) does Python have any polling capabilities? What about threading - if I launched a thread to just "wait" until a time has expired, could I then get that thread to make the main program call a function, or would the main program sit there waiting for the thread to end? I really have no experience with threads in Python, any hints/tutorials, the docs are pretty limited? I'm looking to make this program cross-platform, it has to run on at least Windows and Linux (hopefully MacOSX too) so the solution would have to be portable (does Windows even have threading without POSIX?) If you want to check out what I've done so far (GUI, track info, controls etc.) you'll need XMMS, http://inetctrl.sourceforge.net and my source from http://www.the-jedi.co.uk/downloads/xmmsclient there's also some Windows binaries built with the Cygwin/KDE port. [InetCtrl seems to segfault if you don't have a playlist loaded, so load a playlist first, then enable the general plugin. I must submit a bug report to the author, maybe I could convince him to broadcast when a track ends...] Any help would be excellent, as playlist support and these "timed updates" are about all that's left needing to be done.... -- http://mail.python.org/mailman/listinfo/python-list