You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem? Please describe.
When using Process.wait(pid) to await a child process exiting, it's expected to raise Errno::ECHILD if the process has already terminated. The appropriate response in that case is usually to rescue and proceed without action.
Additionally, there's not an effective way to avoid this error being raised. There's not a simple, portable way to check that a process is not running. Even if there was, there is a race, where the child may exit between checking and calling wait.
Thus in multiprocessing code, you frequently see code like the following:
beginProcess.wait(pid)rescueErrno::ECHILD# this is expected, the child process has terminated before calling waitend
This generally requires ugly code like the following:
disabling the cop for the whole file is undesirable, as there are many other exceptions that you would still want to enforce handling for.
Describe the solution you'd like
It would be nice to have a configuration option for the Lint/HandleExceptions cop that lets you provide a list of exceptions that are allowed to be rescued without handling. It should default to including Errno::ECHILD.
Describe alternatives you've considered
Another option would be to hard-code this case into the cop, since it's fairly common. E.g. if the begin..rescue..end block contains a Process.wait, then the cop should not complain about swallowing Errno::ECHILD
Additional context
N/A
The text was updated successfully, but these errors were encountered:
Is your feature request related to a problem? Please describe.
When using
Process.wait(pid)
to await a child process exiting, it's expected to raiseErrno::ECHILD
if the process has already terminated. The appropriate response in that case is usually to rescue and proceed without action.Additionally, there's not an effective way to avoid this error being raised. There's not a simple, portable way to check that a process is not running. Even if there was, there is a race, where the child may exit between checking and calling
wait
.Thus in multiprocessing code, you frequently see code like the following:
This generally requires ugly code like the following:
disabling the cop for the whole file is undesirable, as there are many other exceptions that you would still want to enforce handling for.
Describe the solution you'd like
It would be nice to have a configuration option for the
Lint/HandleExceptions
cop that lets you provide a list of exceptions that are allowed to be rescued without handling. It should default to includingErrno::ECHILD
.Describe alternatives you've considered
Another option would be to hard-code this case into the cop, since it's fairly common. E.g. if the
begin..rescue..end
block contains aProcess.wait
, then the cop should not complain about swallowingErrno::ECHILD
Additional context
N/A
The text was updated successfully, but these errors were encountered: