fishtest icon indicating copy to clipboard operation
fishtest copied to clipboard

try: except: block to catch recent "FileNotFoundError".

Open vdbergh opened this issue 3 years ago • 4 comments

vdbergh avatar Aug 07 '22 09:08 vdbergh

Made this WIP since there is an issue with error reporting.

vdbergh avatar Aug 07 '22 09:08 vdbergh

Fixed.

vdbergh avatar Aug 07 '22 09:08 vdbergh

Most likely the FileNotFoundError is a red herring. Probably the cutechess command line for the tuning test was just too long (I think the FileNotFoundError occurs only on windows).

vdbergh avatar Aug 08 '22 08:08 vdbergh

@ppigazzini Is anything stopping committing this trivial PR? Each time a FileNotFoundError occurs (cfr the event log) the affected worker will quit (an unclassified exception is a fatal error). It will encourage users to run their workers in a loop (which is not recommended in general).

vdbergh avatar Aug 12 '22 18:08 vdbergh

For me the logical explanation for this error is a cutechess-cli command line that is too long for Windows (note that the error only happens on Windows).

vdbergh avatar Aug 30 '22 18:08 vdbergh

I don't think it is ugly. It is a standard pattern used in many places in the worker: Popen combined with catching OSError and SubprocessError.

vdbergh avatar Sep 02 '22 09:09 vdbergh

The try added in this PR is fine, this 3 level try is ugly. https://github.com/glinscott/fishtest/blob/599898efbd0488741eb67eb413d7daff64f32185/worker/games.py#L1025-L1043

IMO this should work, dropping one nested try and dropping a bare except.

            finally:
                # We nicely ask cutechess-cli to stop.
                try:
                    send_sigint(p)
                except Exception as e:
                    print(
                        "\nException in send_sigint:\n", e, sep="", file=sys.stderr
                    )
                # now wait...
                print(
                    "\nWaiting for cutechess-cli to finish ... ", end="", flush=True
                )
                try:
                    p.wait(timeout=CUTECHESS_KILL_TIMEOUT)
                except subprocess.TimeoutExpired:
                    print("timeout", flush=True)
                    kill_process(p)
                else:
                    print("done", flush=True)

ppigazzini avatar Sep 02 '22 09:09 ppigazzini

Triggered the workers update, thank you @vdbergh :)

ppigazzini avatar Sep 02 '22 10:09 ppigazzini

Most likely the FileNotFoundError is a red herring. Probably the cutechess command line for the tuning test was just too long (I think the FileNotFoundError occurs only on windows).

You are right, see https://github.com/glinscott/fishtest/issues/1360#issuecomment-1248344165

cmd characters upper acceptable limit for subprocess.Popen():

  • 32764 Windows
  • ~418000 Linux ((I got two slightly different values with WSL and Ubuntu)

ppigazzini avatar Sep 15 '22 16:09 ppigazzini