# .... except Interrupted,interrupt: self._reset(interrupt.direction) return # UNHANDLED PROBLEMS except Exception,exc: # Those messages can not be filtered in purpose self.logger.raw('\n'.join([ no_panic, self.me(''), '', str(type(exc)), str(exc), trace(), footer ])) self._reset(direction) return # loop def run (self): back = ACTION.LATER if self._restart else ACTION.CLOSE for direction in ['in','out']: opposite = 'out' if direction == 'in' else 'in' generator = self._[direction]['generator'] if generator: try:
return # .... except Interrupted, interrupt: self._reset(interrupt.direction) return # UNHANDLED PROBLEMS except Exception, exc: # Those messages can not be filtered in purpose self.logger.raw('\n'.join([ no_panic, self.me(''), '', str(type(exc)), str(exc), trace(), footer ])) self._reset(direction) return # loop def run(self): back = ACTION.LATER if self._restart else ACTION.CLOSE for direction in ['in', 'out']: opposite = 'out' if direction == 'in' else 'in' generator = self._[direction]['generator'] if generator: try:
def _run (self): """yield True if we want the reactor to give us back the hand with the same peer loop, None if we do not have any more work to do""" try: for action in self._establish(): yield action for action in self._main(): yield action # CONNECTION FAILURE except NetworkError as network: # we tried to connect once, it failed and it was not a manual request, we stop if self.once and not self._teardown: self.logger.debug('only one attempt to connect is allowed, stopping the peer',self.id()) self.stop() self._reset('closing connection',network) return # NOTIFY THE PEER OF AN ERROR except Notify as notify: if self.proto: try: generator = self.proto.new_notification(notify) try: while True: six.next(generator) yield ACTION.NOW except StopIteration: pass except (NetworkError,ProcessError): self.logger.error('Notification not sent',self.id()) self._reset('notification sent (%d,%d)' % (notify.code,notify.subcode),notify) else: self._reset() return # THE PEER NOTIFIED US OF AN ERROR except Notification as notification: # we tried to connect once, it failed and it was not a manual request, we stop if self.once and not self._teardown: self.logger.debug('only one attempt to connect is allowed, stopping the peer',self.id()) self.stop() self._reset( 'notification received (%d,%d)' % ( notification.code, notification.subcode), notification ) return # RECEIVED a Message TYPE we did not expect except Message as message: self._reset('unexpected message received',message) return # PROBLEM WRITING TO OUR FORKED PROCESSES except ProcessError as process: self._reset('process problem',process) return # .... except Interrupted as interruption: self._reset('connection received before we could fully establish one') return # UNHANDLED PROBLEMS except Exception as exc: # Those messages can not be filtered in purpose self.logger.debug('\n'.join([ NO_PANIC, '', '', str(type(exc)), str(exc), trace(), FOOTER ]),'reactor') self._reset() return
except ProcessError, e: self._reset(direction,'process problem',e) return # .... except Interrupted, i: self._reset(i.direction) return # UNHANDLED PROBLEMS except Exception, e: # Those messages can not be filtered in purpose self.logger.error(self.me('UNHANDLED PROBLEM, please report'),'reactor') self.logger.error(self.me(str(type(e))),'reactor') self.logger.error(self.me(str(e)),'reactor') self.logger.error(trace()) self._reset(direction) return # loop def run (self): if self.reactor.processes.broken(self.neighbor.peer_address): # XXX: we should perhaps try to restart the process ?? self.logger.processes('ExaBGP lost the helper process for this peer - stopping','error') self.stop() return True back = ACTION.later if self._restart else ACTION.close for direction in ['in','out']:
# .... except Interrupted,interruption: self._reset(interruption.direction) return # UNHANDLED PROBLEMS except Exception,exc: # Those messages can not be filtered in purpose self.logger.raw('\n'.join([ no_panic, self.me(''), '', str(type(exc)), str(exc), trace(), footer ])) self._reset(direction) return # loop def run (self): if self.reactor.processes.broken(self.neighbor): # XXX: we should perhaps try to restart the process ?? self.logger.processes('ExaBGP lost the helper process for this peer - stopping','error') self.stop() return True back = ACTION.LATER if self._restart else ACTION.CLOSE
def _run(self): """yield True if we want the reactor to give us back the hand with the same peer loop, None if we do not have any more work to do""" try: for action in self._establish(): yield action for action in self._main(): yield action # CONNECTION FAILURE except NetworkError as network: # we tried to connect once, it failed and it was not a manual request, we stop if self.once and not self._teardown: self.logger.debug( 'only one attempt to connect is allowed, stopping the peer', self.id()) self.stop() self._reset('closing connection', network) return # NOTIFY THE PEER OF AN ERROR except Notify as notify: if self.proto: try: generator = self.proto.new_notification(notify) try: while True: six.next(generator) yield ACTION.NOW except StopIteration: pass except (NetworkError, ProcessError): self.logger.error('Notification not sent', self.id()) self._reset( 'notification sent (%d,%d)' % (notify.code, notify.subcode), notify) else: self._reset() return # THE PEER NOTIFIED US OF AN ERROR except Notification as notification: # we tried to connect once, it failed and it was not a manual request, we stop if self.once and not self._teardown: self.logger.debug( 'only one attempt to connect is allowed, stopping the peer', self.id()) self.stop() self._reset( 'notification received (%d,%d)' % (notification.code, notification.subcode), notification) return # RECEIVED a Message TYPE we did not expect except Message as message: self._reset('unexpected message received', message) return # PROBLEM WRITING TO OUR FORKED PROCESSES except ProcessError as process: self._reset('process problem', process) return # .... except Interrupted as interruption: self._reset( 'connection received before we could fully establish one') return # UNHANDLED PROBLEMS except Exception as exc: # Those messages can not be filtered in purpose self.logger.debug( '\n'.join([ NO_PANIC, '', '', str(type(exc)), str(exc), trace(), FOOTER ]), 'reactor') self._reset() return
def _run(self, direction): """yield True if we want the reactor to give us back the hand with the same peer loop, None if we do not have any more work to do""" try: for action in direction.code(): yield action for action in self._main(direction): yield action # CONNECTION FAILURE except NetworkError as network: # we tried to connect once, it failed and it was not a manual request, we stop if self.once and not self._teardown: self.logger.network( 'only one attempt to connect is allowed, stopping the peer' ) self.stop() self._reset(direction, 'closing connection', network) return # NOTIFY THE PEER OF AN ERROR except Notify as notify: if direction.proto: try: generator = direction.proto.new_notification(notify) try: maximum = 20 while maximum: six.next(generator) maximum -= 1 yield ACTION.NOW if maximum > 10 else ACTION.LATER except StopIteration: pass except (NetworkError, ProcessError): self.logger.network(self.me('NOTIFICATION NOT SENT'), 'error') self._reset( direction, 'notification sent (%d,%d)' % (notify.code, notify.subcode), notify) else: self._reset(direction) return # THE PEER NOTIFIED US OF AN ERROR except Notification as notification: # we tried to connect once, it failed and it was not a manual request, we stop if self.once and not self._teardown: self.logger.network( 'only one attempt to connect is allowed, stopping the peer' ) self.stop() self._reset(direction,'notification received (%d,%d)' \ % (notification.code, notification.subcode), notification) return # RECEIVED a Message TYPE we did not expect except Message as message: self._reset(direction, 'unexpected message received', message) return # PROBLEM WRITING TO OUR FORKED PROCESSES except ProcessError as process: self._reset(direction, 'process problem', process) return # .... except Interrupted as interruption: self._reset(interruption.direction) return # UNHANDLED PROBLEMS except Exception as exc: # Those messages can not be filtered in purpose self.logger.raw('\n'.join([ no_panic, self.me(''), '', str(type(exc)), str(exc), trace(), footer ])) self._reset(direction) return