import pygame pygame.init() print_messsage = pygame.USEREVENT + 0 pygame.time.set_timer(print_messsage, 3000) while True: for event in pygame.event.get(): if event.type == print_messsage: print("hello world") pygame.time.set_timer(print_messsage, 0)