Repository navigation
Run Tcl scripts in a Session, and keep the journal of a session in its worker - #2906
Open
ganeshgore wants to merge 2 commits into
Open
ganeshgore wants to merge 2 commits into
ganeshgore wants to merge 2 commits into
Conversation
ganeshgore
force-pushed
the
session-tcl
branch
from
December 1, 2026 03:42
120a84c to
efc22df
Compare
ganeshgore
force-pushed
the
session-tcl
branch
from
December 2, 2026 05:23
efc22df to
2d1297b
Compare
…a worker RemoteSession(journal=directory) has the worker write the journal of its session, as Session(journal=...) does. A worker that starts again (restart(), a session opened again) goes on with the files that are there: the commands of the restore are not written twice, and a call that ends with the worker is not in it. Session(resume_journal=True) does the same in a process. The script of a yosys command is copied into the journal (scripts/001.ys, ...) and the journal names the copy: the maker of a script often writes the same file again for the next run, and a replay then runs the synthesis that was run. RemoteSession(memory_limit_mb=...) limits the address space of the worker (RLIMIT_AS), for it and the workers that start again, so that a command that fills the memory fails by itself with the error of its allocation, and the worker goes on, instead of taking the machine with it.
Session.tcl(script) runs a Tcl script in an interpreter that the session keeps, so that a loop or a sweep is one call. Every command of the shell is a Tcl command, written as on the command line of the shell, that runs through Session.command(): what it changes is in the journal, as if it had been run from Python. A command that answers in JSON returns its answer as a Tcl dict, and a command that fails is an error of Tcl, which catch takes. The variables and procedures stay for the next script. tcl(script, safe=True) runs the script in a safe interpreter: no files, no programs, none of the commands that run other programs or scripts (ext_exec, source, yosys), and the paths in the arguments must stay in the current directory. tcl(script, fixed_width=True) refuses what fixed_width_refusal() refuses. A script that fails raises TclError (or TclRefused) with what it printed, the trace of Tcl, the commands it ran and the diagnostics of the command that failed. In a RemoteSession the script runs in the worker, and the errors cross the pipe as themselves. Tcl comes with tkinter: a Python without it raises TclError.
tangxifan
force-pushed
the
session-tcl
branch
from
December 2, 2026 21:59
2d1297b to
e094f7c
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stacked on #2905 (base
staged-flow-more).What it adds
Tcl in a Session
Session.tcl(script)runs a Tcl script in an interpreter that the session keeps. Every shell command is a Tcl command, written as on the command line of the shell, and runs throughSession.command(), so the journal has what it changed. A command that answers in JSON returns its answer as a Tcl dict; a command that fails is a Tcl error thatcatchtakes. Variables and procedures stay for the next script.tcl(script, safe=True)runs it in a safe interpreter: no files, no programs, noext_exec/source/yosys, and paths must stay in the current directory.tcl(script, fixed_width=True)refuses whatfixed_width_refusal()refuses.TclError/TclRefusedwith the output, the Tcl trace, the commands that ran and the diagnostics of the failed command (tcl_error,tcl_refused). In aRemoteSessionthe script runs in the worker and the errors cross the pipe as themselves.Journal and memory of a worker
RemoteSession(journal=dir)has the worker write the journal of its session; a worker that starts again goes on with it without writing the restore twice.Session(resume_journal=True)does the same in a process.yosyscommand is copied into the journal (scripts/001.ys, ...), so a replay runs the synthesis that ran.RemoteSession(memory_limit_mb=...)limits the address space of the worker (RLIMIT_AS): a command that fills the memory fails with its allocation error and the worker goes on.Tests
test_tcl(commands as Tcl commands, dict answers, journal, errors, safe interpreter, worker),test_worker_journal(journal of a worker and its restart, kept Yosys scripts and their replay, memory limit), and the Tcl refusals intest_fixed_width.openfpga_flow/tasks/python_binding_testsand the ctest subset pass.Not included