Browse Source

pep8 issues and threading with daemon=True

master
Dirk Alders 2 years ago
parent
commit
af35e83d1f
1 changed files with 9 additions and 3 deletions
  1. 9
    3
      __init__.py

+ 9
- 3
__init__.py View File

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

Loading…
Cancel
Save