当前位置: 首页>>代码示例>>Python>>正文


Python FakeLogger.critical方法代码示例

本文整理汇总了Python中exabgp.logger.FakeLogger.critical方法的典型用法代码示例。如果您正苦于以下问题:Python FakeLogger.critical方法的具体用法?Python FakeLogger.critical怎么用?Python FakeLogger.critical使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在exabgp.logger.FakeLogger的用法示例。


在下文中一共展示了FakeLogger.critical方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: Connection

# 需要导入模块: from exabgp.logger import FakeLogger [as 别名]
# 或者: from exabgp.logger.FakeLogger import critical [as 别名]

#.........这里部分代码省略.........
					if self.defensive and random.randint(0,2):
						raise socket.error(errno.EAGAIN,'raising network error on purpose')

					read = self.io.recv(number)
					if not read:
						self.close()
						self.logger.warning('%s %s lost TCP session with peer' % (self.name(),self.peer),self.session())
						raise LostConnection('the TCP connection was closed by the remote end')
					data += read

					number -= len(read)
					if not number:
						self.logger.debug(LazyFormat('received TCP payload',data),self.session())
						yield data
						return

					yield b''
			except socket.timeout as exc:
				self.close()
				self.logger.warning('%s %s peer is too slow' % (self.name(),self.peer),self.session())
				raise TooSlowError('Timeout while reading data from the network (%s)' % errstr(exc))
			except socket.error as exc:
				if exc.args[0] in error.block:
					message = '%s %s blocking io problem mid-way through reading a message %s, trying to complete' % (self.name(),self.peer,errstr(exc))
					if message != reported:
						reported = message
						self.logger.debug(message,self.session())
					yield b''
				elif exc.args[0] in error.fatal:
					self.close()
					raise LostConnection('issue reading on the socket: %s' % errstr(exc))
				# what error could it be !
				else:
					self.logger.critical('%s %s undefined error reading on socket' % (self.name(),self.peer),self.session())
					raise NetworkError('Problem while reading data from the network (%s)' % errstr(exc))

	def writer (self, data):
		if not self.io:
			# XXX: FIXME: Make sure it does not hold the cleanup during the closing of the peering session
			yield True
			return
		while not self.writing():
			yield False
		self.logger.debug(LazyFormat('sending TCP payload',data),self.session())
		# The first while is here to setup the try/catch block once as it is very expensive
		while True:
			try:
				while True:
					if self.defensive and random.randint(0,2):
						raise socket.error(errno.EAGAIN,'raising network error on purpose')

					# we can not use sendall as in case of network buffer filling
					# it does raise and does not let you know how much was sent
					number = self.io.send(data)
					if not number:
						self.close()
						self.logger.warning('%s %s lost TCP connection with peer' % (self.name(),self.peer),self.session())
						raise LostConnection('lost the TCP connection')

					data = data[number:]
					if not data:
						yield True
						return
					yield False
			except socket.error as exc:
				if exc.args[0] in error.block:
开发者ID:aabdnn,项目名称:exabgp,代码行数:70,代码来源:connection.py


注:本文中的exabgp.logger.FakeLogger.critical方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。