Asynchronous method call in Python without creating threads or forking process?

可紊 提交于 2019-12-01 06:22:04

问题


Some years ago, (for comparison) synchronous JavaScript ajax requests were deprecated because of the overhead.
I’m in the following situation :

def ssh_network_operation_with_paramiko(string):
    server_response=Do_some_stuff_with_null_characters_in_string(string)
    Do_something_with_server_response(server_response)

for i in very_very_large_range
    ssh_network_operation_with_paramiko(i)

Basically, using process or threads would be synonym of creating a fork bomb.

So is it possible to do perform asynchronous calls without creating threads or process like with ajax in JavaScript ? Because all I found currently involve creating threads or process were each of them perform only one function at time.

来源:https://stackoverflow.com/questions/33453581/asynchronous-method-call-in-python-without-creating-threads-or-forking-process

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!