mirror of
https://github.com/faucetsdn/ryu.git
synced 2026-01-24 18:11:24 +01:00
Wrap handler calls in the event loop in a try/except and log exceptions
In order to prevent an exception from terminating the execution of the event loop. Wrapper name also added to hub.py for GreenletExit. Signed-off-by: Victor J. Orlikowski <vjo@duke.edu> Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
This commit is contained in:
parent
db1c93249b
commit
f1f0ca2d16
@ -286,7 +286,17 @@ class RyuApp(object):
|
||||
continue
|
||||
handlers = self.get_handlers(ev, state)
|
||||
for handler in handlers:
|
||||
handler(ev)
|
||||
try:
|
||||
handler(ev)
|
||||
except hub.TaskExit:
|
||||
# Normal exit.
|
||||
# Propagate upwards, so we leave the event loop.
|
||||
raise
|
||||
except:
|
||||
LOG.exception('%s: Exception occurred during handler processing. '
|
||||
'Backtrace from offending handler '
|
||||
'[%s] servicing event [%s] follows.',
|
||||
self.name, handler.__name__, ev.__class__.__name__)
|
||||
|
||||
def _send_event(self, ev, state):
|
||||
self._events_sem.acquire()
|
||||
|
||||
@ -50,7 +50,7 @@ if HUB_TYPE == 'eventlet':
|
||||
# by not propergating an exception to the joiner.
|
||||
try:
|
||||
func(*args, **kwargs)
|
||||
except greenlet.GreenletExit:
|
||||
except TaskExit:
|
||||
pass
|
||||
except:
|
||||
# log uncaught exception.
|
||||
@ -67,7 +67,7 @@ if HUB_TYPE == 'eventlet':
|
||||
# by not propergating an exception to the joiner.
|
||||
try:
|
||||
func(*args, **kwargs)
|
||||
except greenlet.GreenletExit:
|
||||
except TaskExit:
|
||||
pass
|
||||
except:
|
||||
# log uncaught exception.
|
||||
@ -87,13 +87,14 @@ if HUB_TYPE == 'eventlet':
|
||||
# greenthread
|
||||
try:
|
||||
t.wait()
|
||||
except greenlet.GreenletExit:
|
||||
except TaskExit:
|
||||
pass
|
||||
|
||||
Queue = eventlet.queue.LightQueue
|
||||
QueueEmpty = eventlet.queue.Empty
|
||||
Semaphore = eventlet.semaphore.Semaphore
|
||||
BoundedSemaphore = eventlet.semaphore.BoundedSemaphore
|
||||
TaskExit = greenlet.GreenletExit
|
||||
|
||||
class StreamServer(object):
|
||||
def __init__(self, listen_info, handle=None, backlog=None,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user