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


Python DbClient.deleteMessageFromOutbox方法代码示例

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


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

示例1: flushOutboxInSeparateThread

# 需要导入模块: from dbclient import DbClient [as 别名]
# 或者: from dbclient.DbClient import deleteMessageFromOutbox [as 别名]
	def flushOutboxInSeparateThread(self):
		'''This can take quite a while to do the flush'''
		if self._flushing:
			return
		print("Outgoing postman is flushing the outbox...")
		self._flushing = True
		# Look in the outbox for messages
		messagesFound = 0
		messagesSent  = 0
		failedRecpts = set()
		for m in DbClient.getOutboxMessages():
			messagesFound += 1
			# Get recipient, timestamp, relays, message
			message = m['message']
			sendTimestamp = m.get('timestamp', None) # not used yet
			# TODO: if the timestamp is too old, then either just delete the message (if it's not to be queued) or move to inbox

			# Some messages have a single recipient (and maybe relays), others only have a recipientList
			recipient = m.get('recipient', None)
			if recipient:
				sendSuccess = self.RC_MESSAGE_FAILED if recipient in failedRecpts else self.sendMessage(message, recipient)
				if sendSuccess == self.RC_MESSAGE_IGNORED:
					print("Dealt with message so I should delete it from the db:", m["_id"])
					DbClient.deleteMessageFromOutbox(m["_id"])
				elif sendSuccess == self.RC_MESSAGE_SENT:
					print("Sent message so I should delete it from the db:", m["_id"])
					DbClient.deleteMessageFromOutbox(m["_id"])
					messagesSent += 1
					testMsg = "Message sent, type was %s and recipient was %s" % (m.get("msgType", "unknown"), recipient)
					# TODO: Pass these values with the signal as an object, not a string
					self.emit(QtCore.SIGNAL("messageSent"), testMsg)
				elif not m.get('queue', False):
					print("I failed to send a message but it shouldn't be queued, deleting it")
					DbClient.deleteMessageFromOutbox(m["_id"])
					failedRecpts.add(recipient)
				else:
					print("I failed to send but I'll keep the message and try again later")
					failedRecpts.add(recipient)
			else:
				# There isn't a direct recipient, so let's hope there's a recipient list
				recipientList = m.get('recipientList', None)
				if recipientList:
					print("I've got a message to relay to: ", recipientList)
					failedRecipientsForThisMessage = set()
					# TODO: Try to send to each in the list
		# TODO: Does the parent even need to know when a send has worked?
		if messagesSent > 0:
			self.parent.postmanKnock() # only once
		if messagesFound > 0:
			print("For %d found messages, I managed to send %d copies" % (messagesFound, messagesSent))
		# We tried to send a message to these recipients but failed - set them to be offline
		for r in failedRecpts:
			Contacts.goneOffline(r)
		self._flushing = False
开发者ID:activityworkshop,项目名称:Murmeli,代码行数:56,代码来源:postmen.py


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