def shutdown_all_inbox_packets(): """ """ if _Debug: lg.out( _DebugLevel, 'gateway.shutdown_all_inbox_packets, %d live objects at the moment' % len(packet_in.items().values())) for pkt_in in list(packet_in.items().values()): pkt_in.event('cancel', 'shutdown')
def packets_timeout_loop(): global _PacketsTimeOutTask # lg.out(18, 'gateway.packets_timeout_loop') delay = 5 if _Debug: delay = 1 _PacketsTimeOutTask = reactor.callLater(delay, packets_timeout_loop) for pkt_in in packet_in.items().values(): if pkt_in.is_timed_out(): if _Debug: lg.out( _DebugLevel - 4, 'gateway.packets_timeout_loop %r is timed out: %s' % (pkt_in, pkt_in.timeout)) pkt_in.automat('cancel', 'timeout') for pkt_out in packet_out.queue(): if pkt_out.is_timed_out(): if _Debug: lg.out( _DebugLevel - 4, 'gateway.packets_timeout_loop %r is timed out: %s' % (pkt_out, pkt_out.timeout)) pkt_out.automat('cancel', 'timeout') if _Debug and lg.is_debug(_DebugLevel): monitoring()
def current_bytes_received(): res = {} # for transfer_id, info in transfers_in().items(): # res[transfer_id] = info.size for pkt_in in packet_in.items().values(): res[pkt_in.transfer_id] = pkt_in.size return res
def shutdown_all_inbox_packets(): """ """ if _Debug: lg.out( _DebugLevel, "gateway.shutdown_all_inbox_packets, %d live objects at the moment" % len(packet_in.items().values()), ) for pkt_in in list(packet_in.items().values()): pkt_in.event("cancel", "shutdown")
def monitoring(): list_pkt_in = [] for pkt_in in packet_in.items().values(): list_pkt_in.append(pkt_in.label) list_pkt_out = [] for pkt_out in packet_out.queue(): list_pkt_out.append(pkt_out.label) if transport_log() and list_pkt_out and list_pkt_in: dt = time.time() - lg.when_life_begins() mn = dt // 60 sc = dt - mn * 60 transport_log().write("%02d:%02d in: %s out: %s\n" % (mn, sc, list_pkt_in, list_pkt_out)) transport_log().flush()
def monitoring(): list_pkt_in = [] for pkt_in in packet_in.items().values(): list_pkt_in.append(pkt_in.label) list_pkt_out = [] for pkt_out in packet_out.queue(): list_pkt_out.append(pkt_out.label) if transport_log() and list_pkt_out and list_pkt_in: dt = time.time() - lg.when_life_begins() mn = dt // 60 sc = dt - mn * 60 transport_log().write('%02d:%02d in: %s out: %s\n' % (mn, sc, list_pkt_in, list_pkt_out)) transport_log().flush()
def _list_in_out_packets(params): result = [] for pkt_out in packet_out.queue(): result.append({ 'name': pkt_out.outpacket.Command, 'label': pkt_out.label, 'from_to': 'to', 'target': pkt_out.remote_idurl, }) for pkt_in in packet_in.items().values(): result.append({ 'name': pkt_in.transfer_id, 'label': pkt_in.label, 'from_to': 'from', 'target': pkt_in.sender_idurl, }) return {'result': result, }
def packets_timeout_loop(): global _PacketsTimeOutTask # lg.out(18, 'gateway.packets_timeout_loop') delay = 5 if _Debug: delay = 1 _PacketsTimeOutTask = reactor.callLater(delay, packets_timeout_loop) for pkt_in in packet_in.items().values(): if pkt_in.is_timed_out(): lg.out(8, "gateway.packets_timeout_loop %r is timed out" % pkt_in) pkt_in.automat("cancel", "timeout") for pkt_out in packet_out.queue(): if pkt_out.is_timed_out(): lg.out(8, "gateway.packets_timeout_loop %r is timed out" % pkt_out) pkt_out.automat("cancel", "timeout") if _Debug and lg.is_debug(_DebugLevel): monitoring()
def _list_in_out_packets(params): result = [] for pkt_out in packet_out.queue(): result.append({ 'name': pkt_out.outpacket.Command, 'label': pkt_out.label, 'from_to': 'to', 'target': pkt_out.remote_idurl, }) for pkt_in in packet_in.items().values(): result.append({ 'name': pkt_in.transfer_id, 'label': pkt_in.label, 'from_to': 'from', 'target': pkt_in.sender_idurl, }) return { 'result': result, }