mirror of
https://github.com/JoelBender/bacpypes
synced 2025-09-28 22:15:23 +08:00
add __lt__ function to make tasks orderable (so heappush is happy in py34), update metaclass syntax in py34 singleton
This commit is contained in:
parent
bbcf3c2bc0
commit
11caa8a18a
|
@ -92,6 +92,9 @@ class _Task(DebugContents, Logging):
|
|||
|
||||
_task_manager.resume_task(self)
|
||||
|
||||
def __lt__(self, other):
|
||||
return id(self) < id(other)
|
||||
|
||||
#
|
||||
# OneShotTask
|
||||
#
|
||||
|
|
|
@ -92,6 +92,9 @@ class _Task(DebugContents, Logging):
|
|||
|
||||
_task_manager.resume_task(self)
|
||||
|
||||
def __lt__(self, other):
|
||||
return id(self) < id(other)
|
||||
|
||||
#
|
||||
# OneShotTask
|
||||
#
|
||||
|
|
|
@ -56,18 +56,18 @@ class _SingletonMetaclass(type):
|
|||
# Singleton
|
||||
#
|
||||
|
||||
class Singleton(object):
|
||||
class Singleton(metaclass=_SingletonMetaclass):
|
||||
|
||||
__metaclass__ = _SingletonMetaclass
|
||||
pass
|
||||
|
||||
#
|
||||
# _SingletonLoggingMetaclass
|
||||
#
|
||||
|
||||
class _SingletonLoggingMetaclass(_SingletonMetaclass, debugging._LoggingMetaclass):
|
||||
|
||||
pass
|
||||
|
||||
class SingletonLogging(object):
|
||||
|
||||
__metaclass__ = _SingletonLoggingMetaclass
|
||||
class SingletonLogging(metaclass=_SingletonLoggingMetaclass):
|
||||
|
||||
pass
|
||||
|
|
|
@ -92,6 +92,9 @@ class _Task(DebugContents, Logging):
|
|||
|
||||
_task_manager.resume_task(self)
|
||||
|
||||
def __lt__(self, other):
|
||||
return id(self) < id(other)
|
||||
|
||||
#
|
||||
# OneShotTask
|
||||
#
|
||||
|
|
|
@ -203,4 +203,4 @@ class TestTimeMachine(unittest.TestCase):
|
|||
# function called, no time has passed
|
||||
assert ft1.process_task_called == 4
|
||||
assert ft2.process_task_called == 3
|
||||
assert time_machine.current_time == 5.0
|
||||
assert time_machine.current_time == 5.0
|
||||
|
|
Loading…
Reference in New Issue
Block a user