@@ -15,21 +15,27 @@ def __init__(self, server="localhost:6379", password=None):
1515 raise Exception ("Bad server argument" )
1616
1717 def register_signal_handlers (self ):
18+ print 'registering signals'
1819 signal .signal (signal .SIGTERM , self .schedule_shutdown )
1920 signal .signal (signal .SIGINT , self .schedule_shutdown )
2021 signal .signal (signal .SIGQUIT , self .schedule_shutdown )
2122
22- def schedule_shutdown (self ):
23+ def schedule_shutdown (self , signal , frame ):
24+ print 'shutting down started'
2325 self ._shutdown = True
2426
25- def run (self ):
27+ def __call__ (self ):
28+ print 'starting up'
2629 self .register_signal_handlers ()
2730 #self.load_schedule()
31+ print 'looking for delayed items'
2832 while True :
2933 if self ._shutdown is True :
3034 break
3135 self .handle_delayed_items ()
36+ print 'sleeping'
3237 time .sleep (5 )
38+ print 'shutting down complete'
3339
3440 def next_timestamp (self ):
3541 while True :
@@ -50,12 +56,18 @@ def next_item(self, timestamp):
5056
5157 def handle_delayed_items (self ):
5258 for timestamp in self .next_timestamp ():
59+ print 'handling timestamp: %s' % timestamp
5360 for item in self .next_item (timestamp ):
54- print 'queueing item'
61+ print 'queueing item %s' % item
5562 klass = item ['class' ]
5663 queue = item ['queue' ]
5764 args = item ['args' ]
58- self .resq .enqueue_from_string (klass , queue , args )
65+ self .resq .enqueue_from_string (klass , queue , * args )
5966
6067
68+ @classmethod
69+ def run (cls , server , password = None ):
70+ sched = cls (server = server , password = password )
71+ sched ()
6172
73+
0 commit comments