Skip to content

Instantly share code, notes, and snippets.

@wolf0403
Last active August 29, 2015 14:07
Show Gist options
  • Save wolf0403/8edab44b5eaf3078c6b1 to your computer and use it in GitHub Desktop.
Save wolf0403/8edab44b5eaf3078c6b1 to your computer and use it in GitHub Desktop.
Bound method as callback
import sched, time
class O(object):
def __init__(self, name):
self.name = name
def print_time(self):
print("({}): From print_time {}".format(self.name, time.time()))
def entry(self):
s = sched.scheduler(time.time, time.sleep)
s.enter(2, 1, self.print_time, ())
s.run()
runner = O('runner')
runner.entry()
# Output:
# (runner): From print_time 1412821256.22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment