McCode
McCode copied to clipboard
Scanning via `mcrun -N` can fail due to `STDOUT` capture
Problem
When run in 'scan' mode, mcrun
captures STDOUT
and STDERR
in order to identify detector lines.
https://github.com/McStasMcXtrace/McCode/blob/c725e6fcd621f1103b37b5d46c913be60df8dc1a/tools/Python/mcrun/optimisation.py#L261
For not-entirely-clear reasons, in some cases the scan can hang indefinitely -- possibly due to overflowing the buffer as seems to be indicated in the Popen.communicate documentation
Solution
This problem is fixed by switching from STDOUT
parsing to reading the requisite information back from each scan-point mccode.sim
file, and not capturing either STDOUT
or STDERR
.
Side effects
If change is implemented
Scan progress indication
Output from each simulation step in the scan will be sent to STDOUT
allowing a user to easily identify that a long-running process is progressing instead of wondering why no output is produced, in contrast to the single-point (no -N
) mode of mcrun
.
If no change is implemented
Possible undefined behavior
In its current state, a user could inadvertently break mcrun
in scan mode by writing a component that produces lines which match the regular expression used to identify detectors
https://github.com/McStasMcXtrace/McCode/blob/c725e6fcd621f1103b37b5d46c913be60df8dc1a/tools/Python/mcrun/mccode.py#L379