简体   繁体   English

使用Stackless Python保存大型正在运行的程序的状态?

[英]Using Stackless Python to save the state of a large running program?

Given a large (4.5 GB codebase) python testing framework whose execution involves many tens of files, many of which are not directly pickle-able, is it possible to wrap initial execution of the program in a one line function, create a Stackless tasklet around that function, and, during execution, pickle the tasklet as a way of saving the whole program's state? 给定一个大型(4.5 GB代码库)python测试框架,其执行涉及数十个文件,其中许多不是直接可腌制的,是否有可能将程序的初始执行包装在一行函数中,从而创建一个Stackless Tasklet该函数,并在执行过程中对任务小程序进行腌制,以保存整个程序的状态? What is the limit of Stackless' tasklet pickling capabilities? Stackless的tasklet酸洗功能有什么限制?

This is indeed a possibility offered by Stackless Pickling 这确实是无堆浸酸洗提供的可能性

One of the main features of Stackless is its ability to pickle and unpickle tasklets. Stackless的主要功能之一是其腌制和释放小任务的能力。 That means that a running program inside a tasklet can be persistently stored to a file or string. 这意味着Tasklet中正在运行的程序可以持久存储到文件或字符串中。 Later, it can be restored again and can continue to run at the point where it was previously halted. 以后,它可以再次还原,并且可以在先前停止的位置继续运行。 This need not be on the same machine!: 不必在同一台机器上!:

So to our question "is it possible" the answer is "yes". 因此,对于我们的问题“是否可能”,答案是“是”。

As a matter of "how to do it", I think the link above provide a concrete example. 关于“如何做”,我认为上面的链接提供了一个具体的例子。 Try it and post an other question if it doesn't work. 尝试一下,然后发布另一个问题,如果它不起作用。 Given the size of your code base (4.5GB of Python source files is rather huge!), maybe you will reach the limits of Stackless? 给定代码库的大小(4.5GB的Python 文件相当大!),也许您会达到Stackless的极限?

To be more concrete: Stackless adds pickling support to a number of built in elements, such as execution frames and modules and other runtime objects However, code, such as classes, functions and modules, are all pickled by name. 更具体地讲:Stackless为许多内置元素(例如执行框架和模块以及其他运行时对象)添加了酸洗支持。但是,诸如名称,功能和模块之类的代码都按名称被酸洗。 What this means is that on the other machine, the same objects must be accessable through the import mechanism. 这意味着在另一台计算机上,必须可以通过导入机制访问相同的对象。
In other words, the pickled execution state will contain the current local variables and all that, but the contents of code objects, or modules will not be picled. 换句话说,腌制的执​​行状态将包含当前的局部变量及其所有内容,但是将不对代码对象或模块的内容进行腌制。 These need to be accessible by name when the state is unpickled. 当状态未选取时,需要按名称访问这些文件。

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

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