如何检查FrontEnd是否认为评估仍在运行? [英] How to check whether the FrontEnd considers evaluation still running?

查看:77
本文介绍了如何检查FrontEnd是否认为评估仍在运行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以通过编程方式检查FrontEnd是否认为评估仍在运行? 甚至更好:是否有办法检查FrontEnd是否有一些待处理的输入要发送到内核?

P.S.此问题来自上一个问题.

编辑

在前端评估单元时,通常会为内核创建一个输入队列.

我需要一个函数,如果FrontEnd已将EvaluationNotebook[]中输入队列的最后一个输入发送到内核,则该函数将返回True.换句话说,如果当前输入是FrontEnd生成的输入队列的最后一个输入,则我需要一个返回True的函数.

解决方案

这应该有效.当然,您必须在与要执行评估的内核不同的内核中运行它.

NotebookEvaluatingQ[nb_] := (
 SelectionMove[nb, All, Notebook];
 Or @@ Map["Evaluating" /. # &, Developer`CellInformation[nb]]
)

Is there a way to check programmatically whether the FrontEnd considers evaluation still running? Or even better: is there a way to check whether the FrontEnd has some pending inputs to be sent to the kernel?

P.S. This question has arisen from previous question.

EDIT

When evaluating a Cell in the FrontEnd we usually create a queue of inputs for the kernel.

I need a function that will return True if the FrontEnd has sent to the kernel the last input of the queue of inputs from the EvaluationNotebook[]. Or in other words I need a function that returns True if this current input is the last input of the queue of inputs generated by the FrontEnd.

解决方案

This should work. Of course, you have to run it in a different kernel than the one that is performing the evaluation you want to check for.

NotebookEvaluatingQ[nb_] := (
 SelectionMove[nb, All, Notebook];
 Or @@ Map["Evaluating" /. # &, Developer`CellInformation[nb]]
)

这篇关于如何检查FrontEnd是否认为评估仍在运行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆