mirror of https://github.com/citusdata/citus.git
Merge pull request #5722 from citusdata/avoid-exceptional-control-flow-in-fluent-py
fluent.py: prefer simpler return based control flow in _accept rather than relying on raising an exceptionpull/5688/head
commit
854f6036a9
|
@ -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):
|
||||||
'''
|
'''
|
||||||
|
|
Loading…
Reference in New Issue