submit-same.py
603 Bytes
"""把 8011 上某条已完成任务的请求原样投给另一个端口,用来做单变量对照。"""
import json, sys, urllib.request
src_port, dst_port, job_id = sys.argv[1], sys.argv[2], sys.argv[3]
with urllib.request.urlopen(f"http://127.0.0.1:{src_port}/v1/videos/{job_id}", timeout=30) as r:
req = json.load(r)["req"]
body = json.dumps(req).encode()
post = urllib.request.Request(f"http://127.0.0.1:{dst_port}/v1/videos", data=body,
headers={"Content-Type": "application/json"})
with urllib.request.urlopen(post, timeout=30) as r:
print(json.load(r))