Closed lseppala closed 6 months ago
related link https://github.com/cosmtrek/air/pull/397
But I think this solution is better, with nice backward compatibility considerations.
I think the code is great but could u add more test cases for it, once the code is covered i will merge it
@xiantang Tests cases added. Let me know if you want something different.
All modified and coverable lines are covered by tests :white_check_mark:
Comparison is base (
af962ce
) 70.24% compared to head (c28d9a8
) 69.31%. Report is 34 commits behind head on master.
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
kill_delay
is parsed as a Duration (ref). When given as an integer (as in the example config), it is interpreted as nanoseconds, not milliseconds. The sleep will be too short to allow a program to respond to the interrupt and stop cleanly. This change allows the number to be interpreted as milliseconds.This change is made to preserve backwards compatibility. If the value is specified as an value under 1 millisecond/1 000 000 nanoseconds, like
500
in the example config, the value will be interpreted as the number of milliseconds. For users who figured out that you may specify the time as a duration string like”2s”
or use large nanosecond integers like2000000000
for 2 seconds, the behavior will remain the same.An alternative is changing
kill_delay
to be parsed as an integer, likedelay
andrerun_delay
. This will break users who used duration strings or large numbers.This may be the root cause of the problem reported in #216, as a sufficient value for
kill_delay
to allow a program to stop gracefully solved this problem for me.