Python 中的带宽限制

2022-01-19 00:00:00 python networking network-programming

问题描述

有哪些库可以让您控制网络请求(尤其是 http)的下载速度.我没有看到 urllib2 中的任何内置内容(也没有在我打算使用的 (Py)Qt 中).

What libraries out there let you control the download speed of network requests (http in particular). I don't see anything built-in in urllib2 (nor in (Py)Qt which I intend on using).

Twisted 可以控制带宽吗?如果没有,如何控制 urllib2 或 Twisted 的读取缓冲区大小?sleep不能暂停网络操作.

Can Twisted control bandwidth? If not, how can I control the read buffer size of urllib2 or Twisted? sleeping to suspend network operations isn't an option.


解决方案

当然twisted可以.你想要 twisted.protocols.policies.ThrottlingFactory.只需将现有工厂包装在其中,然后再将其传递给任何想要的工厂.

Of course twisted can. You want twisted.protocols.policies.ThrottlingFactory. Just wrap your existing factory in it before you pass it to whatever wants a factory.

相关文章