Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/298.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 如何解决此RuntimeWarning错误?_Python_Httpx - Fatal编程技术网

Python 如何解决此RuntimeWarning错误?

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(

嘿:)我想用async和httpx编写一些代码。这是我的错误:RuntimeWarning:coroutine“AsyncClient.get”从未被等待过 与client.get(f)异步https://websitename/{self.pid}”)作为res: RuntimeWarning:启用tracemalloc以获取对象分配回溯 aexit我知道https://websitename/{self.pid}不作为网站存在,但我不能泄露网站哈哈

这是我的代码:


        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
。。???