def get_new_file_name(): # return tempfile._get_candidate_names() global ci while True: ci += 1 ci = ci % max_file_i yield str(ci)