简体   繁体   English

python到“流”字典处理

[英]python to “stream” dictionary processing

I have an algorithm in python that does an exhaustive search of possibilities given a set of inputs. 我在python中有一个算法,可以在给定一组输入的情况下详尽地搜索各种可能性。

This is hooked up to a web application and can take up to 15 seconds to fully process. 这已连接到Web应用程序,最多可能需要15秒才能完成处理。

So...yes I want to eventually improve on the algo and process quicker, but I'd also like to include a visualization that streams the possibilities python is working with until it arrives at a solution. 所以...是的,我希望最终改进算法并更快地处理,但我还想提供一个可视化视图,该可视化视图可以处理python正在使用的可能性,直到找到解决方案为止。

In my terminal, python generates the list of possibilities line by line until it finds a combo that satisfies the requirements 在我的终端中,python逐行生成可能性列表,直到找到满足要求的组合

How can I hook Python's terminal output up with my client-side framework 如何将Python的终端输出与我的客户端框架连接起来

Ideally it would simulate the terminal's output and the user can see evidence that the algo is running while they wait. 理想情况下,它将模拟终端的输出,并且用户可以在等待时看到算法正在运行的证据。

Would I convert the output to bytes, open a socket, and then stream the data within my application as I deserialize it? 我是否将输出转换为字节,打开套接字,然后在反序列化时在应用程序中传输数据?

You can do this using websockets. 您可以使用websockets执行此操作。 Generally, you would have a separate socket server running, like socket.io . 通常,您将运行一个单独的套接字服务器,例如socket.io Both your web server and client-side javascript would connect to the socket server and communicate back and forth, or in your case, just continuously sending messages to the client. 您的Web服务器和客户端javascript都将连接到套接字服务器并来回通信,或者在您的情况下,只是连续地向客户端发送消息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM