crawl4ai
crawl4ai copied to clipboard
异步报错,无法创建子进程
在更开始安装完之后,调用这个示例没有问题,但是,在我将异步agnet加到的代码中之后,就会出现,这个错误,初夏这个错误之后,再将代码恢复示例的样子,无法运行。大佬有空看一下,谢谢
@sujin502 Sorry to hear that you encountered a bug after changing to the new version. Could you share the code snippet with me on how you're using it? However, by just looking at your code, I see that there may be something wrong with your Windows operating system and a synchronous event loop. First, try to install Redis (pip install redis), then also maybe you can change the event loop policy to a PreactorEventLoop, following the code below. Also, ensure that you have Playwright properly installed and then see how it goes; this problem likely has something to do with your operating system. Nonetheless, I will be more helpful when I see your code.
import asyncio
if sys.platform == "win32":
asyncio.set_event_loop_policy(asyncio.WindowsProactorEventLoopPolicy())
很遗憾听到您在更改为新版本后遇到了错误。您能否与我分享一下您如何使用它的代码片段?但是,仅通过查看您的代码,我发现您的 Windows 操作系统和同步事件循环可能存在问题。首先,尝试安装 Redis (),然后您也可以按照下面的代码将事件循环策略更改为 PreactorEventLoop。此外,请确保您已正确安装 Playwright,然后查看其运行情况;此问题可能与您的操作系统有关。尽管如此,当我看到您的代码时,我会更有帮助。
pip install redisimport asyncio if sys.platform == "win32": asyncio.set_event_loop_policy(asyncio.WindowsProactorEventLoopPolicy())
我找到原因了,这个问题是因为我和agently一起使用的原因,我也不知道为什么,只要playwright和agently一起使用(导入一个文件中,不管他们相隔几个文件,)只要这两个见面就会导致异步错误,我的解决方法是,将playwright做成api接口,就可以避免这个情况
@sujin502 I can see now the problem, so I suggest running the docker and then communicating with the crawler4ai through the docker server, you can call the API and then use it anywhere else that you want; no need to make any changes on Playwright if this is an option for you.
@sujin502 Closing this issue due to inactivity. Please open a new issue if the problem still persists.
我现在能看出问题所在了,所以我建议运行 docker,然后通过 docker 服务器与 crawler4ai 通信,你可以调用 API,然后在其他任何你想要的地方使用它;如果这是您的选择,则无需在 Playwright 上进行任何更改。
我已经将 crawler4ai做成了api用来调用通信