在Python异步HTTP调用

在Python异步HTTP调用

本文介绍了在Python异步HTTP调用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在Python回调样的功能我在哪里发送请求到WebService多次,在参数每次的变化。我想这些请求发生的同时而不是按顺序的,所以我希望函数进行异步调用。

I have a need for a callback kind of functionality in Python where I am sending a request to a webservice multiple times, with a change in the parameter each time. I want these requests to happen concurrently instead of sequentially, so I want the function to be called asynchronously.

看起来asyncore是我可能要使用,但我已经看到它是如何工作的例子看起来都像矫枉过正,所以我不知道是否有其他路径我应该下降。模块/流程有什么建议?理想情况下,我想在一个程序的方式来使用这些,而不是创建类的,但我未必能够得到解决的。

It looks like asyncore is what I might want to use, but the examples I've seen of how it works all look like overkill, so I'm wondering if there's another path I should be going down. Any suggestions on modules/process? Ideally I'd like to use these in a procedural fashion instead of creating classes but I may not be able to get around that.

推荐答案

仅仅是这个票据。但是,如果你不想采取上也可以使用,与libcurl包装,有它自己的异步事件循环,支持回调。

Twisted framework is just the ticket for that. But if you don't want to take that on you might also use pycurl, wrapper for libcurl, that has its own async event loop and supports callbacks.

这篇关于在Python异步HTTP调用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-19 23:21