equal
deleted
inserted
replaced
94 from . import ( |
94 from . import ( |
95 node, |
95 node, |
96 pycompat, |
96 pycompat, |
97 urllibcompat, |
97 urllibcompat, |
98 util, |
98 util, |
|
99 ) |
|
100 from .utils import ( |
|
101 procutil, |
99 ) |
102 ) |
100 |
103 |
101 httplib = util.httplib |
104 httplib = util.httplib |
102 urlerr = util.urlerr |
105 urlerr = util.urlerr |
103 urlreq = util.urlreq |
106 urlreq = util.urlreq |
633 print(format % ('keepalive readline', node.hex(m.digest()))) |
636 print(format % ('keepalive readline', node.hex(m.digest()))) |
634 |
637 |
635 def comp(N, url): |
638 def comp(N, url): |
636 print(' making %i connections to:\n %s' % (N, url)) |
639 print(' making %i connections to:\n %s' % (N, url)) |
637 |
640 |
638 util.stdout.write(' first using the normal urllib handlers') |
641 procutil.stdout.write(' first using the normal urllib handlers') |
639 # first use normal opener |
642 # first use normal opener |
640 opener = urlreq.buildopener() |
643 opener = urlreq.buildopener() |
641 urlreq.installopener(opener) |
644 urlreq.installopener(opener) |
642 t1 = fetch(N, url) |
645 t1 = fetch(N, url) |
643 print(' TIME: %.3f s' % t1) |
646 print(' TIME: %.3f s' % t1) |
644 |
647 |
645 util.stdout.write(' now using the keepalive handler ') |
648 procutil.stdout.write(' now using the keepalive handler ') |
646 # now install the keepalive handler and try again |
649 # now install the keepalive handler and try again |
647 opener = urlreq.buildopener(HTTPHandler()) |
650 opener = urlreq.buildopener(HTTPHandler()) |
648 urlreq.installopener(opener) |
651 urlreq.installopener(opener) |
649 t2 = fetch(N, url) |
652 t2 = fetch(N, url) |
650 print(' TIME: %.3f s' % t2) |
653 print(' TIME: %.3f s' % t2) |
685 fo.close() |
688 fo.close() |
686 |
689 |
687 i = 20 |
690 i = 20 |
688 print(" waiting %i seconds for the server to close the connection" % i) |
691 print(" waiting %i seconds for the server to close the connection" % i) |
689 while i > 0: |
692 while i > 0: |
690 util.stdout.write('\r %2i' % i) |
693 procutil.stdout.write('\r %2i' % i) |
691 util.stdout.flush() |
694 procutil.stdout.flush() |
692 time.sleep(1) |
695 time.sleep(1) |
693 i -= 1 |
696 i -= 1 |
694 util.stderr.write('\r') |
697 procutil.stderr.write('\r') |
695 |
698 |
696 print(" fetching the file a second time") |
699 print(" fetching the file a second time") |
697 fo = urlreq.urlopen(url) |
700 fo = urlreq.urlopen(url) |
698 data2 = fo.read() |
701 data2 = fo.read() |
699 fo.close() |
702 fo.close() |