import urllib, urllib2 from threading import Timer history = [] def queue( typ, data ): history.append( { "type":typ, "data":data } ) def persist(): print "hi" if __name__ == "__main__": queue( "file" , "aaa") queue( "foo" , "bbb") queue( "foo" , "ccc") queue( "file" , "ddd") t = Timer( 5.0, persist ) t.start()