使用多个线程执行单个for循环(Using multiple threads to execute a single for loop)
我可以使用多个线程在python中执行单个for循环吗? 我的意思是,我的循环有大量的迭代,所以我想同时运行多个线程,每个线程可以执行一定数量的循环迭代。
假设迭代次数在很高的数量级。 例如10 ** 9。
而且,如果这是可能的,它是否会减少完成for循环执行所需的时间....?
Can I use multiple threads to execute a single for loop in python? I mean, my loop has huge number of iterations and so I would like to run multiple threads simultaneously in such a way that each thread can execute a certain number of iteration of the loop.
Assume that the number of iterations is in high orders of magnitude. 10**9 for example.
And also, if this is possible, does it reduce the time it requires to complete the execution of the for loop....?
原文:https://stackoverflow.com/questions/30964415
满意答案
问题是没有调用webService。
您没有提供任何相关证据,也无法从您发布的代码中分辨出来。
getOutputStream()返回一个没有来自WebService的消息的OutputStream。
这毫无意义。
OutputStreams
不包含来自对等体的消息。 它们用于向对等方发送消息。 这句话和你的头衔完全没有意义。无论如何都要检查WebService是否已成功调用?
是。 阅读响应并返回,而不是硬连线
"OK"
。而你刚刚发布的代码就是这样做的。
同意它不是最漂亮的代码。
它甚至不是正确的代码。 HTTP标头无效,它不会尝试读取响应。 这只是无能。 使用您发布的HttpURLConnection代码。
The problem is that the webService is not called.
You haven't provided any evidence to that effect, and it is impossible to tell from the code you've posted.
The getOutputStream() retuns an OutputStream that has no message from the WebService.
This is meaningless.
OutputStreams
don't contain messages from the peer. They are used to send messages to the peer. This statement and your title are completely nonsensical.Is there anyway to check that the WebService has been called successfully?
Yes. Read the response, and return it, instead of hardwiring
"OK"
.And you've just posted code that does exactly that.
Agreed it is not the most beautiful code.
It isn't even correct code. The HTTP headers are invalid, and it makes no attempt to read a response. It's just incompetent. Use the HttpURLConnection code you posted.
相关问答
更多具有XML内容的CXF Webservice响应(CXF Webservice response with XML content)
Webservice发送其WSDL定义作为其响应(Webservice sending its WSDL definition as its response)
从WebService检索响应消息(Retrieving response message from WebService)
从javascript调用webservice并等待响应(calling webservice from javascript and wait for response)
优化Web服务响应消息(Optimizing webservice response message)
如果在指定时间内没有响应,则丢弃Webservice调用(Discard Webservice call if no response in specified time)
使用POST方法的webservice响应“不支持的媒体类型”(webservice response “Unsupported Media Type” with POST method)
IIS Webservice,怪异的404 http响应代码(IIS Webservice, weird 404 http response code)
异步调用webservice(Call webservice asynchronously)
如何从webservice返回响应(How to return response from webservice)
相关文章
更多Storm-源码分析-Topology Submit-Executor-mk-threads
[转]So You Want To Be A Producer
Spark - A Fault-Tolerant Abstraction for In-Memory Cluster Computing
Stack Overflow Architecture Update - Now At 95 Million Page Views A Month
Solr: a custom Search RequestHandler
A Great List of Windows Tools
Spring Data: a new perspective of data operations
Create a Bootable MicroSD Card
Drupal Forums instead of phpBB or vBulletin: A casestudy
Hadoop 1.2.1 单节点安装(Single Node Setup)步骤
最新问答
更多获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
如何通过引用返回对象?(How is returning an object by reference possible?)
矩阵如何存储在内存中?(How are matrices stored in memory?)
每个请求的Java新会话?(Java New Session For Each Request?)
css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
xcode语法颜色编码解释?(xcode syntax color coding explained?)
在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
Copyright ©2023 peixunduo.com All Rights Reserved.粤ICP备14003112号
本站部分内容来源于互联网,仅供学习和参考使用,请莫用于商业用途。如有侵犯你的版权,请联系我们(neng862121861#163.com),本站将尽快处理。谢谢合作!