multithreading - Python timer not waiting as expected -
so, have code:
t = threading.timer(570.0, reddit_post(newmsg)) t.start()
to start quick reddit post. sadly, instead of waiting 570 seconds, automatically executes reddit_post without waiting.
what can fix this?
to explain in more detail:
when call timer constructor, should give 3 arguments. first argument should how long want timer wait. second argument should callable (for example function). third argument should list of arguments call function.
an example.
# first define function call. def say_hello(name): print('hello ' + name) # can call function. say_hello('john') # when make timer call later, use not call function. timer = threading.timer(10, say_hello, ['john']) timer.start()
Comments
Post a Comment