mercurial/keepalive.py
changeset 30473 39d13b8c101d
parent 30463 bc0def54c17d
child 30487 88a448a12ae8
equal deleted inserted replaced
30472:277f4fe6d01a 30473:39d13b8c101d
   658     print(format % ('keepalive readline', m.hexdigest()))
   658     print(format % ('keepalive readline', m.hexdigest()))
   659 
   659 
   660 def comp(N, url):
   660 def comp(N, url):
   661     print('  making %i connections to:\n  %s' % (N, url))
   661     print('  making %i connections to:\n  %s' % (N, url))
   662 
   662 
   663     sys.stdout.write('  first using the normal urllib handlers')
   663     util.stdout.write('  first using the normal urllib handlers')
   664     # first use normal opener
   664     # first use normal opener
   665     opener = urlreq.buildopener()
   665     opener = urlreq.buildopener()
   666     urlreq.installopener(opener)
   666     urlreq.installopener(opener)
   667     t1 = fetch(N, url)
   667     t1 = fetch(N, url)
   668     print('  TIME: %.3f s' % t1)
   668     print('  TIME: %.3f s' % t1)
   669 
   669 
   670     sys.stdout.write('  now using the keepalive handler       ')
   670     util.stdout.write('  now using the keepalive handler       ')
   671     # now install the keepalive handler and try again
   671     # now install the keepalive handler and try again
   672     opener = urlreq.buildopener(HTTPHandler())
   672     opener = urlreq.buildopener(HTTPHandler())
   673     urlreq.installopener(opener)
   673     urlreq.installopener(opener)
   674     t2 = fetch(N, url)
   674     t2 = fetch(N, url)
   675     print('  TIME: %.3f s' % t2)
   675     print('  TIME: %.3f s' % t2)
   710     fo.close()
   710     fo.close()
   711 
   711 
   712     i = 20
   712     i = 20
   713     print("  waiting %i seconds for the server to close the connection" % i)
   713     print("  waiting %i seconds for the server to close the connection" % i)
   714     while i > 0:
   714     while i > 0:
   715         sys.stdout.write('\r  %2i' % i)
   715         util.stdout.write('\r  %2i' % i)
   716         sys.stdout.flush()
   716         util.stdout.flush()
   717         time.sleep(1)
   717         time.sleep(1)
   718         i -= 1
   718         i -= 1
   719     sys.stderr.write('\r')
   719     util.stderr.write('\r')
   720 
   720 
   721     print("  fetching the file a second time")
   721     print("  fetching the file a second time")
   722     fo = urlreq.urlopen(url)
   722     fo = urlreq.urlopen(url)
   723     data2 = fo.read()
   723     data2 = fo.read()
   724     fo.close()
   724     fo.close()