我用的是简单的请求.post()连接到服务器并接收数据的模块
ack = requests.post('<ip>/get_data, data=data, timeout=10.0, verify=False)
下面是服务器中使用zmq poller接收数据直到获得最终响应的get_data()方法。在
^{pr2}$在服务器端,获得的响应记录如下:
2017-08-28_07:17:55.43370 WARNING: Iteration: 1, Length of Rows: 100
2017-08-28_07:17:55.44269 WARNING: Iteration: 2, Length of Rows: 100
2017-08-28_07:17:55.44894 WARNING: Iteration: 3, Length of Rows: 100
2017-08-28_07:17:55.45742 WARNING: Iteration: 4, Length of Rows: 100
2017-08-28_07:17:55.46327 WARNING: Iteration: 5, Length of Rows: 100
2017-08-28_07:17:55.46687 WARNING: Iteration: 6, Length of Rows: 100
2017-08-28_07:17:55.47074 WARNING: Iteration: 7, Length of Rows: 100
2017-08-28_07:17:55.47658 WARNING: Iteration: 8, Length of Rows: 100
2017-08-28_07:17:55.48385 WARNING: Last Iteration: 9, Length of Rows: 75
所以,我假设我在服务器端实现的zmq轮询器工作得非常好。但是,我很想知道如何将这9次迭代的数据发送回请求的客户机?在
P.S. I want to receive the data continuously in client side. You may suggest appending each batch of response somewhere and sending the final response back to the client. This won't be feasible when the response is too big (The requesting client would get timeout)
好吧, 我使用Flask模块的Response对象处理了这个问题。调用一个单独的方法来连续地生成数据并生成最终的响应对象并返回它,解决了我的问题。在
相关问题 更多 >
编程相关推荐