如何配置 sched.run() 继续程序而不是等待?
How to configure sched.run() to continue the program instead of waiting?
我有一个 Python 注册计划任务的代码,应该继续执行程序的其余部分(它放在我的服务器后端)。
import sched, time
def pri():
print "A"
s= sched.scheduler(time.time, time.sleep)
s.enter(60, 1, pri, ())
s.run
print "Hello"
我希望程序在执行计划任务之前打印Hello
,然后继续程序的其余部分。
有人知道怎么做吗?
我用线程解决了它:
import sched, time
import thread
def pri():
print "A"
def schedule_task():
s= sched.scheduler(time.time, time.sleep)
s.enter(60, 1, pri, ())
s.run
thread.create_new_thread(schedule_task, (,))
print "Hello"
我有一个 Python 注册计划任务的代码,应该继续执行程序的其余部分(它放在我的服务器后端)。
import sched, time
def pri():
print "A"
s= sched.scheduler(time.time, time.sleep)
s.enter(60, 1, pri, ())
s.run
print "Hello"
我希望程序在执行计划任务之前打印Hello
,然后继续程序的其余部分。
有人知道怎么做吗?
我用线程解决了它:
import sched, time
import thread
def pri():
print "A"
def schedule_task():
s= sched.scheduler(time.time, time.sleep)
s.enter(60, 1, pri, ())
s.run
thread.create_new_thread(schedule_task, (,))
print "Hello"