Should execute-general-script Run On A Thread?

9 views
Skip to first unread message

tbp1...@gmail.com

unread,
May 4, 2022, 5:37:57 PM5/4/22
to leo-editor
the execute-general-script command runs scripts, including @file and @clean external files, outside of the leo environment.  the command has some bells and whistles, including the ability to receive the program's output and display clickable links in the log pane.  in this regard, it is much like the pylint and mypy commands.

however, unlike them the command blocks leo.  leo is frozen until the launched program returns.  we fixed that with the pylint and mypy commands by running them with threads.  any number of instances of those commands can be launched, and they queue up and wait their turn without blocking leo.

i have my own program-launching script that doesn't block (and has fewer bells and whistles).  it does not block leo, though it also does not communicate anything back to leo. since i usually use it to run long-running or gui programs, this works well.  you don't want a server you are developing to block leo, for example, and you are not looking to get any output.  and you want to see any error messages as they happen.

here i want to open a discussion of whether the execute-general-script should be made to be non-blocking.  if yes, there are some complications, such as where the output should go when several instances of the command are running at the same time, and whether several instances should even be allowed to run at the same time.  maybe. for example, the command should queue itself up with the background process manager.

or maybe the command should remain unchanged and a new, similar one be added. 

i am inclined to think that such a command should open a new tab in the log frame and write to it.   one difficulty of the present approach to communication between the launched program and leo is that leo receives no data until the launched program returns.  there is a technical problem with reliably getting data as it comes in - at least on windows - but presumably this could be overcome in some way.

thoughts and suggestions about this command welcome.

Edward K. Ream

unread,
May 6, 2022, 10:13:33 AM5/6/22
to leo-editor
On Wed, May 4, 2022 at 4:37 PM tbp1...@gmail.com <tbp1...@gmail.com> wrote:

here i want to open a discussion of whether the execute-general-script should be made to be non-blocking.

Yes, that would be good.
  if yes, there are some complications, such as where the output should go when several instances of the command are running at the same time, and whether several instances should even be allowed to run at the same time.  maybe. for example, the command should queue itself up with the background process manager.

I agree. Use the BPM if possible.
i am inclined to think that such a command should open a new tab in the log frame and write to it. 

Imo (which can always change), using the log is simple and best (less confusing). It's almost never necessary to do several background tasks at once, and even if there is, the BPM is the best way to keep things straight.

If you really want to do lots of things at once, you can do them outside of Leo.

Summary

Using the BPM to avoid confusion will be simplest and will be adequate virtually all the time. I look forward to your PR!

Edward
Reply all
Reply to author
Forward
0 new messages