아미(아름다운미소)

python [timer] 파이썬에서 n 초마다 반복적으로 함수를 실행하는 또다른 방법 본문

랭귀지/PYTHON

python [timer] 파이썬에서 n 초마다 반복적으로 함수를 실행하는 또다른 방법

유키공 2018. 10. 16. 09:30

범용 이벤트 스케줄러를 구현하는 sched 모듈을 사용하는 방법도 있습니다.

import sched, time
s = sched.scheduler(time.time, time.sleep)
def do_something(sc): 
    print "반복실행..."
    s.enter(60, 1, do_something, (sc,))

s.enter(60, 1, do_something, (s,))
s.run()


Comments