Skip to content

Commit

Permalink
Use hasattr to determine if handler is callable
Browse files Browse the repository at this point in the history
  • Loading branch information
noahfrn committed Feb 24, 2024
1 parent df692b6 commit 17ddcd8
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions cryptofeed/backends/aggregate.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,13 @@
class AggregateCallback:
def __init__(self, handler):
self.handler = handler
if not callable(self.handler):
setattr(self, 'start', self.handler.start)
setattr(self, 'stop', self.handler.stop)
if (
hasattr(self.handler, "__class__")
and hasattr(self.handler, "start")
and hasattr(self.handler, "stop")
):
setattr(self, "start", self.handler.start)
setattr(self, "stop", self.handler.stop)
self.__name__ = self.handler.__class__


Expand Down

0 comments on commit 17ddcd8

Please sign in to comment.