Closed marconiho closed 11 months ago
There's pretty much nothing to go on from your report. What actually happens on Mac OS? Do you get a response, or it hits a timeout or what?
The code appears to just do a simple GET request, so it's unlikely an aiohttp problem... There could be an issue with a firewall or any number of things.
async with session.get(url, params=params) as res
There is no response when the program runs to this line of code.But in Windows, I can receive the expected results normally.Or maybe I can receive the results in a different way even under macOS,Like this:
`
def __event_stream(url, params):
response = requests.get(url, params=params, stream=True)
event_data = ""
for line in response.iter_lines():
if line:
event_data += line.decode() + "\n"
elif event_data:
yield event_data
event_data = ""
code_id_map_em = code_to_em_symbol('300498')
url = "https://70.push2.eastmoney.com/api/qt/stock/details/sse"
params = {
"fields1": "f1,f2,f3,f4",
"fields2": "f51,f52,f53,f54,f55",
"mpi": "2000",
"ut": "bd1d9ddb04089700cf9c27f6f7426281",
"fltt": "2",
"pos": "-0",
"secid": f"{code_id_map_em}",
"wbp2u": "|0|0|0|web",
}
big_df = pd.DataFrame()
for event in __event_stream(url, params):
event_json = json.loads(event.replace("data: ", ""))
temp_df = pd.DataFrame(
[item.split(",") for item in event_json["data"]["details"]]
)
big_df = pd.concat([big_df, temp_df], ignore_index=True)
break
print(big_df)
`
But, what does "no response" mean? What actually happens? Either res
has been set to something, or you would get an exception (maybe a timeout after waiting a bit).
I found that there was an issue with adding an HTTPS request, and when I switched to an HTTP request, it worked fine
Describe the bug
Under mac os, ClientSession fails to request the stream interface. This problem does not exist under Windows.
To Reproduce
async def stock_intraday_em(symbol: str = "000001") -> pd.DataFrame: code_id_map_em = code_to_em_symbol(symbol) url = "https://70.push2.eastmoney.com/api/qt/stock/details/sse" params = { "fields1": "f1,f2,f3,f4", "fields2": "f51,f52,f53,f54,f55", "mpi": "2000", "ut": "bd1d9ddb04089700cf9c27f6f7426281", "fltt": "2", "pos": "-0", "secid": f"{code_id_map_em}", "wbp2u": "|0|0|0|web", }
df = await stock_intraday_em('300498')
Expected behavior
fix this bug
Logs/tracebacks
Python Version
aiohttp Version
multidict Version
yarl Version
OS
macOs Sonoma
Related component
Client
Additional context
No response
Code of Conduct