Python 如何解决此RuntimeWarning错误?
嘿:)我想用async和httpx编写一些代码。这是我的错误:RuntimeWarning:coroutine“AsyncClient.get”从未被等待过 与client.get(f)异步https://websitename/{self.pid}”)作为res: RuntimeWarning:启用tracemalloc以获取对象分配回溯 aexit我知道https://websitename/{self.pid}不作为网站存在,但我不能泄露网站哈哈 这是我的代码:Python 如何解决此RuntimeWarning错误?,python,httpx,Python,Httpx,嘿:)我想用async和httpx编写一些代码。这是我的错误:RuntimeWarning:coroutine“AsyncClient.get”从未被等待过 与client.get(f)异步https://websitename/{self.pid}”)作为res: RuntimeWarning:启用tracemalloc以获取对象分配回溯 aexit我知道https://websitename/{self.pid}不作为网站存在,但我不能泄露网站哈哈 这是我的代码: log(
log(f"[{str(datetime.datetime.now()).split(' ')[1]}] [{self.task_index}] [{self.countryName}] Fetching product info", "alt")
while True:
try:
async with httpx.AsyncClient() as client:
async with client.get(f"https://websitename/{self.pid}") as res:
mainLink = await res.text()
except Exception as e:
print(e)
await asyncio.sleep(self.delay)
else:
if res.status not in (200, 302):
log(f"[{str(datetime.datetime.now()).split(' ')[1]}] [{self.task_index}] [{self.countryName}] Error getting info", "error")
await asyncio.sleep(self.delay)
else:
soup = BeautifulSoup(mainLink, features="html.parser")```
您是否搜索到错误消息:
RuntimeWarning:coroutine'AsyncClient.get'从未与站点async:stackoverflow.com
。。???