|
@@ -159,13 +159,14 @@ class threaded_queue(queue):
|
159
|
159
|
|
160
|
160
|
.. literalinclude:: task/_examples_/threaded_queue.log
|
161
|
161
|
"""
|
|
162
|
+
|
162
|
163
|
def __init__(self, expire=False):
|
163
|
164
|
queue.__init__(self, expire=expire)
|
164
|
165
|
self.thread = None
|
165
|
166
|
|
166
|
167
|
def run(self):
|
167
|
168
|
if self.thread is None:
|
168
|
|
- self.thread = threading.Thread(target=self._start, args=())
|
|
169
|
+ self.thread = threading.Thread(target=self._start, args=(), daemon=True)
|
169
|
170
|
self.thread.daemon = True # Daemonize thread
|
170
|
171
|
self.thread.start() # Start the execution
|
171
|
172
|
|
|
@@ -206,6 +207,7 @@ class periodic(object):
|
206
|
207
|
|
207
|
208
|
.. literalinclude:: task/_examples_/periodic.log
|
208
|
209
|
"""
|
|
210
|
+
|
209
|
211
|
def __init__(self, cycle_time, callback, *args, **kwargs):
|
210
|
212
|
self._lock = threading.Lock()
|
211
|
213
|
self._timer = None
|
|
@@ -253,6 +255,7 @@ class periodic(object):
|
253
|
255
|
self._timer = threading.Timer(0, self._start)
|
254
|
256
|
else:
|
255
|
257
|
self._timer = threading.Timer(self.cycle_time, self._start)
|
|
258
|
+ self._timer.daemon = True
|
256
|
259
|
self._timer.start()
|
257
|
260
|
self._lock.release()
|
258
|
261
|
|
|
@@ -281,6 +284,7 @@ class delayed(periodic):
|
281
|
284
|
|
282
|
285
|
.. literalinclude:: task/_examples_/delayed.log
|
283
|
286
|
"""
|
|
287
|
+
|
284
|
288
|
def run(self):
|
285
|
289
|
"""
|
286
|
290
|
This starts the timer for the delayed execution.
|
|
@@ -329,12 +333,14 @@ class crontab(periodic):
|
329
|
333
|
"""
|
330
|
334
|
class all_match(set):
|
331
|
335
|
"""Universal set - match everything"""
|
|
336
|
+
|
332
|
337
|
def __contains__(self, item):
|
333
|
338
|
(item)
|
334
|
339
|
return True
|
335
|
340
|
|
336
|
341
|
def __init__(self, minute, hour, day_of_month, month, day_of_week, callback, *args, **kwargs):
|
337
|
|
- self.set_trigger_conditions(minute or crontab.ANY, hour or crontab.ANY, day_of_month or crontab.ANY, month or crontab.ANY, day_of_week or crontab.ANY)
|
|
342
|
+ self.set_trigger_conditions(minute or crontab.ANY, hour or crontab.ANY,
|
|
343
|
+ day_of_month or crontab.ANY, month or crontab.ANY, day_of_week or crontab.ANY)
|
338
|
344
|
self.callback = callback
|
339
|
345
|
self.args = args
|
340
|
346
|
self.kwargs = kwargs
|
|
@@ -369,7 +375,7 @@ class crontab(periodic):
|
369
|
375
|
def __conv_to_set__(self, obj):
|
370
|
376
|
if obj is crontab.ANY:
|
371
|
377
|
return self.all_match()
|
372
|
|
- elif isinstance(obj, (int, long) if sys.version_info < (3,0) else (int)):
|
|
378
|
+ elif isinstance(obj, (int, long) if sys.version_info < (3, 0) else (int)):
|
373
|
379
|
return set([obj])
|
374
|
380
|
else:
|
375
|
381
|
return set(obj)
|