Dan
Dan

Reputation: 929

How to configure sched.run() to continue the program instead of waiting?

I have a Python code that registers a schedule task and should continue to execute the rest of the program (It placed on my server backend).

import sched, time

def pri():
        print "A"

s= sched.scheduler(time.time, time.sleep)
s.enter(60, 1, pri, ())
s.run

print "Hello"

I want the program to print Hello before executing the scheduled task, and continue the rest of the program.

Does anyone knows how to do that?

Upvotes: 0

Views: 51

Answers (1)

Dan
Dan

Reputation: 929

I solved it using threading:

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"

Upvotes: 1

Related Questions