From: P2P-Next Date: Tue, 21 Sep 2010 06:32:52 +0000 (+0300) Subject: next-share: print time-based peer information X-Git-Url: http://p2p-next.cs.pub.ro/gitweb/?a=commitdiff_plain;h=6aeea6eab4eec8d912ef9ae61728dd19ee157ea1;p=cs-p2p-next.git next-share: print time-based peer information When peer logging is enabled print information each PEERLIST_OUTPUT_INTERVAL seconds starting from the epoch in order to ensure common time around test systems. --- diff --git a/instrumentation/next-share/BaseLib/Tools/cmdlinedl.py b/instrumentation/next-share/BaseLib/Tools/cmdlinedl.py index 5dff96b..0f7594c 100644 --- a/instrumentation/next-share/BaseLib/Tools/cmdlinedl.py +++ b/instrumentation/next-share/BaseLib/Tools/cmdlinedl.py @@ -60,12 +60,9 @@ def print_version(): # use -l/--peer-logging option to enable peer logging peer_logging = False -# number of state_callback calls to print peer list information +# print peer list information each PEERLIST_OUTPUT_INTERVAL seconds PEERLIST_OUTPUT_INTERVAL = 5 -# number of callback counts -callback_count = 0 - # Print torrent statistics def state_callback(ds): d = ds.get_download() @@ -81,14 +78,11 @@ def state_callback(ds): if not peer_logging: return (1.0, peer_logging) - # peer listing each PEERLIST_OUTPUT_INTERVAL state_callback calls - global callback_count - callback_count = callback_count + 1 - - if callback_count == PEERLIST_OUTPUT_INTERVAL: - callback_count = 0 - peerlist = ds.get_peerlist() + # peer listing each PEERLIST_OUTPUT_INTERVAL seconds + seconds_since_epoch = int(time.time()) + if seconds_since_epoch % PEERLIST_OUTPUT_INTERVAL == 0: print >>sys.stderr, '--Peers: (%s) ' % (time.strftime("%b %d %H:%M:%S", time.localtime())), + peerlist = ds.get_peerlist() if peerlist is None or not peerlist: pass else: