Skip to content

Commit

Permalink
removing return and adding comment for handling defer being none
Browse files Browse the repository at this point in the history
  • Loading branch information
EmanElsaban committed Jan 25, 2024
1 parent 0855f4c commit b111843
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions tron/kubernetes.py
Original file line number Diff line number Diff line change
Expand Up @@ -356,17 +356,18 @@ def handle_next_event(self, _=None) -> None:
self.deferred = self.queue.get()
if self.deferred is None:
log.warning("Unable to get a handler for next event in queue - this should never happen!")
return
# TODO: figure out how to recover if we were unable to get a handler
# Not adding a callback is very bad here as this means we will never handle this event
# we want to process the event we just popped off the queue, but we also want
# to form a sort of event loop, so we add two callbacks:
# * one to actually deal with the event
# * and another to grab the next event, in this way creating an event loop :)
self.deferred.addCallback(self.process_event)
self.deferred.addCallback(self.handle_next_event)
self.deferred.addCallback(self.process_event) # type: ignore
self.deferred.addCallback(self.handle_next_event) # type: ignore

# should an exception be thrown, these callbacks will be run instead
self.deferred.addErrback(logError)
self.deferred.addErrback(self.handle_next_event)
self.deferred.addErrback(logError) # type: ignore
self.deferred.addErrback(self.handle_next_event) # type: ignore

def process_event(self, event: Event) -> None:
"""
Expand Down

0 comments on commit b111843

Please sign in to comment.