This commit is contained in:
Maximilian Hils 2016-09-24 22:12:02 -07:00 committed by GitHub
parent eeec17902f
commit afe6bf0309
2 changed files with 19 additions and 9 deletions

View File

@ -478,21 +478,31 @@ class Pathoc(tcp.TCPClient):
def main(args): # pragma: no cover def main(args): # pragma: no cover
memo = set([]) memo = set()
trycount = 0
p = None p = None
if args.repeat == 1:
requests = args.requests
else:
# If we are replaying more than once, we must convert the request generators to lists
# or they will be exhausted after the first run.
# This is bad for the edge-case where get:/:x10000000 (see 0da3e51) is combined with -n 2,
# but does not matter otherwise.
requests = [list(x) for x in args.requests]
try: try:
cnt = 0 requests_done = 0
while True: while True:
if cnt == args.repeat and args.repeat != 0: if requests_done == args.repeat:
break break
if args.wait and cnt != 0: if args.wait and requests_done > 0:
time.sleep(args.wait) time.sleep(args.wait)
cnt += 1 requests_done += 1
playlist = itertools.chain(*args.requests)
if args.random: if args.random:
playlist = random.choice(args.requests) playlist = random.choice(requests)
else:
playlist = itertools.chain.from_iterable(requests)
p = Pathoc( p = Pathoc(
(args.host, args.port), (args.host, args.port),
ssl=args.ssl, ssl=args.ssl,

View File

@ -50,7 +50,7 @@ def args_pathoc(argv, stdout=sys.stdout, stderr=sys.stderr):
) )
parser.add_argument( parser.add_argument(
"-n", dest='repeat', default=1, type=int, metavar="N", "-n", dest='repeat', default=1, type=int, metavar="N",
help='Repeat N times. If 0 repeat for ever.' help='Repeat N times. Pass -1 to repeat infinitely.'
) )
parser.add_argument( parser.add_argument(
"-w", dest='wait', default=0, type=float, metavar="N", "-w", dest='wait', default=0, type=float, metavar="N",