mirror of
https://github.com/JoelBender/bacpypes
synced 2025-09-28 22:15:23 +08:00
add some debugging
This commit is contained in:
parent
cb47cd6639
commit
c63f0d4996
|
@ -160,15 +160,20 @@ def FunctionTask(fn, *args, **kwargs):
|
|||
# RecurringTask
|
||||
#
|
||||
|
||||
@bacpypes_debugging
|
||||
class RecurringTask(_Task):
|
||||
|
||||
_debug_contents = ('taskInterval',)
|
||||
|
||||
def __init__(self, interval=None):
|
||||
if _debug: RecurringTask._debug("__init__ interval=%r", interval)
|
||||
_Task.__init__(self)
|
||||
|
||||
# save the interval, but do not automatically install
|
||||
self.taskInterval = interval
|
||||
|
||||
def install_task(self, interval=None):
|
||||
if _debug: RecurringTask._debug("install_task interval=%r", interval)
|
||||
global _task_manager, _unscheduled_tasks
|
||||
|
||||
# set the interval if it hasn't already been set
|
||||
|
@ -181,6 +186,7 @@ class RecurringTask(_Task):
|
|||
|
||||
# if there is no task manager, postpone the install
|
||||
if not _task_manager:
|
||||
if _debug: RecurringTask._debug(" - no task manager")
|
||||
_unscheduled_tasks.append(self)
|
||||
|
||||
else:
|
||||
|
@ -188,6 +194,7 @@ class RecurringTask(_Task):
|
|||
now = _task_manager.get_time()
|
||||
interval = self.taskInterval / 1000.0
|
||||
self.taskTime = now + interval - (now % interval)
|
||||
if _debug: RecurringTask._debug(" - task time: %r", self.taskTime)
|
||||
|
||||
# install it
|
||||
_task_manager.install_task(self)
|
||||
|
|
Loading…
Reference in New Issue
Block a user