lingua-franca
lingua-franca copied to clipboard
C target with docker property produces no output
When building an LF application for the C target with the docker property enabled, programs which contain a timer do not produce output when run.
target C {
docker: true
}
main reactor {
timer t(0, 1s);
reaction(t) {=
printf("tick\n");
=}
}
Expected output: "tick" every 1s
Actual result: Only output produced:
---- System clock resolution: 1 nsec
The program is running (verified by publishing heartbeat messages to InfluxDB), but output is not visible.
When removing docker = true this works as expected. Similarly the Python target with timers also works.
Workaround
Add --tty to the docker run command, or tty: true to the docker-compose file.
Suggested fix
Add tty: true to the docker compose file.
I assume that this happened because
- unlike our tests, this program does not terminate, so there isn't an obvious time to flush buffers
- the volume of output produced is very small (5 chars/second), so some buffer never becomes full.
I think that both of these conditions need to hold in order for this problem to be observed. Therefore, this problem could be less likely to surface in a typical program than one might guess based on the simplicity of this misbehaving example.
The proposed fix makes sense to me. @petervdonovan Do you see any reason not to add tty: true?
I can push a fix for this today.
@petervdonovan this really tripped up Erling, since many of the federates in the AVP demo only output that they started and have no other console output. He couldn't tell they were running. If just one error is produced, it may not appear.