【发布时间】:2014-04-21 18:54:40
【问题描述】:
当我在 Windows 7 中使用带有 asyncio 和 Python 3.4 的 aiohttp 库发出 HTTPS 请求时,请求失败并在 base_events.py 中的 _make_ssl_transport 函数中出现 NotImplementedError,如回溯中所示。
在 Windows 上,我使用 ProactorEventLoop。我认为你必须使用那个来让 asyncio 工作。我在带有 Python 3.4 编译版本的 Debian 7 VM 中尝试了相同的请求,并且相同的请求有效。我不使用 Debian 中的 ProactorEventLoop,只是默认的。
有什么想法或解决方法吗?或者,我现在应该放弃 Windows 上的 aiohttp HTTPS 吗?我无法在这个项目中使用 Linux,需要在 Windows 上。
【问题讨论】:
-
你需要
ProactorEventLoop()到read output from subprocesses' pipes usingasyncio。尝试使用默认循环(删除 set_event_loop() 调用)来发出 https 请求。 -
这似乎行得通,但唯一的问题是,当我关闭循环时,我总是会得到一个异常,即使没有更多的待处理任务。
-
这只是意味着您的代码中存在多个问题。创建minimal complete code example 和post it as a question
-
@J.F.Sebastian - 您之前关于使用默认事件循环的评论适用于 Windows 上的 HTTPS,谢谢。 ProactorEventLoop 似乎不起作用。如果在 Windows 上的 Python 中运行 shell 命令和 HTTP(S) 请求,我想我需要 2 个循环。
-
你可以post your comment as an answer and accept it: 1. ProactorEventLoop 与 SSL 不兼容 2. 默认循环在 Windows 上支持 SSL,通过扩展 aiohttp 也应该在 Windows 上与 https 一起使用。
标签: python windows python-3.x python-asyncio