def queue_packet(self, packet):
"""Queues sending a packet to its intended owner"""
connection_id = packet.get_receiver_connection_id()
if not self.socket_is_open(connection_id):
# Warn if there is no socket to send through for the expected recip
shared_utils.print_and_log(
logging.WARN,
'Can not send packet to worker_id {}: packet queue not found. '
'Message: {}'.format(connection_id, packet.data)
)
return
shared_utils.print_and_log(
logging.DEBUG,
'Put packet ({}) in queue ({})'.format(packet.id, connection_id)
)
# Get the current time to put packet into the priority queue
self.packet_map[packet.id] = packet
item = (time.time(), packet)
self._safe_put(connection_id, item)
评论列表
文章目录