You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
i'm trying to use grequests to check live stream ,i just expect a status_code 200,so i use stream = True and close it
my code like :
class ExInfoAdapter(HTTPAdapter):
def send(self, request, **kwargs):
request.raw_info = request.headers.pop("data", None)
return super(ExInfoAdapter, self).send(request, **kwargs)
cdnsession = requests.session()
cdnsession.headers.update(self.header)
retries = Retry(total=2, backoff_factor=0, status_forcelist=[500, 502, 503, 504, 404], raise_on_redirect=False)
cdnsession.mount('http://', ExInfoAdapter(max_retries=retries, pool_connections=200, pool_maxsize=400))
cdnsession.mount('https://', ExInfoAdapter(max_retries=retries, pool_connections=200, pool_maxsize=400))
for ...
greqs.append(grequests.get(
"http://{rip}/live/{zuid}.flv".format(rip=ip, zuid=zuid),
headers={"Host": host,
"data": json.dumps( # this will pop out and never send to server
{"rip": ip, "zuid": zuid, "domain": domain, "type": ctype})},
timeout=15,
session=cdnsession
))
def fqecp(request, exception):
return [request, exception]
resps = grequests.imap(greqs, stream=True, size=200, exception_handler=fqecp)
for resp in resps:
if isinstance(resp, list): # handle err
rd = json.loads(resp[0].kwargs["headers"].get("data", None))
gerrs[rd['type']].append(rd)
else:
rd = json.loads(resp.request.raw_info)
if resp.status_code != 200:
gerrs[rd['type']].append(rd)
print("non-200 : %s" % resp.status_code)
else:
pass
# print("%s check ok" % resp.url)
resp.close()
it workd fine and prety faster than just requests,but by checking net usage,it seems like stream=True not effect
last 5 low:
it semms like keep download until close() .
i tried requests in shell with stream=True,code like:
import requests
from requests.adapters import HTTPAdapter
from requests.packages.urllib3.util.retry import Retry
class ExInfoAdapter(HTTPAdapter):
def send(self, request, **kwargs):
request.raw_info = request.headers.pop("data", None)
return super(ExInfoAdapter, self).send(request, **kwargs)
s=requests.Session()
retries = Retry(total=2, backoff_factor=0, status_forcelist=[500, 502, 503, 504, 404], raise_on_redirect=False)
s.mount('http://', ExInfoAdapter(max_retries=retries, pool_connections=200, pool_maxsize=400))
s.mount('https://', ExInfoAdapter(max_retries=retries, pool_connections=200, pool_maxsize=400))
r=s.get("http://116.207.172.73/live/2358590143_1603765853.flv",headers={"Host": "v2.zb.marketing.i.mi.com"},timeout=15,stream=True)
assert r.status_code == 200
r.close()
# this ip and url may unavilable when you try,please find another live stream or call me to get a new one
here 's the result:
i tryedboth grequests and requests 2 times , grequests download avg 3MB(2.8and3.2) and requests download avg 322KB(321and323)
323KB is mach accessable but still a lot,i just want to chek http code ,it's still a lot
where's my fault and how to resolve this issue?
The text was updated successfully, but these errors were encountered:
Python 3.8.3 (default, May 19 2020, 06:50:17) [MSC v.1916 64 bit (AMD64)] :: Anaconda, Inc. on win32
i'm trying to use grequests to check live stream ,i just expect a status_code 200,so i use stream = True and close it
my code like :
it workd fine and prety faster than just requests,but by checking net usage,it seems like stream=True not effect
last 5 low:
it semms like keep download until close() .
i tried requests in shell with stream=True,code like:
here 's the result:
i tryedboth grequests and requests 2 times , grequests download avg 3MB(2.8and3.2) and requests download avg 322KB(321and323)
323KB is mach accessable but still a lot,i just want to chek http code ,it's still a lot
where's my fault and how to resolve this issue?
The text was updated successfully, but these errors were encountered: