fluent.py: prefer simpler return based control flow in _accept rather than relying on raising an exception

pull/5722/head
Philip Dubé 2022-02-17 12:56:40 +00:00
parent 754d894375
commit e4420a6252
1 changed files with 4 additions and 13 deletions

View File

@ -20,9 +20,6 @@ logging.basicConfig(format="%(asctime)s %(levelname)s %(message)s", level=loggin
# I. Command Strings # I. Command Strings
class Stop(Exception):
pass
class Handler: class Handler:
''' '''
This class hierarchy serves two purposes: This class hierarchy serves two purposes:
@ -46,19 +43,13 @@ class Handler:
if not self.next: if not self.next:
raise Exception("we don't know what to do!") raise Exception("we don't know what to do!")
try: if self.next._accept(flow, message) == 'stop':
self.next._accept(flow, message)
except Stop:
if self.root is not self: if self.root is not self:
raise return 'stop'
self.next = KillHandler(self) self.next = KillHandler(self)
flow.kill() flow.kill()
elif result == 'done': else:
# stop processing this packet, move on to the next one return result
return
elif result == 'stop':
# from now on kill all connections
raise Stop()
def _handle(self, flow, message): def _handle(self, flow, message):
''' '''