+ # Select a random image and check if we've seen it recently;
+ # loop until we can find a new image (never seen before) or old enough.
+ for i in xrange(len(images)): # ensure the loop is not infinite
+ image_name = random.choice(images)
+ if global_db.has_key(image_name):
+ image_time = global_db[image_name]
+ if current_time - image_time > min_delay:
+ break
+ else:
+ break
+ global_db[image_name] = current_time
+