Skip to content
This repository has been archived by the owner on May 4, 2021. It is now read-only.

Close engines in a proper way #38

Closed
tico-tico opened this issue Apr 5, 2017 · 1 comment
Closed

Close engines in a proper way #38

tico-tico opened this issue Apr 5, 2017 · 1 comment

Comments

@tico-tico
Copy link
Contributor

Some engines like ProDeo really prefer to be closed in a proper way sending quit instead of just killing the process.
Here's a proposed change for EngineThread.py.

[...]
import sys
[...]

    def close(self):
        self.working = False
        if self.pid:
            self.put_line("quit")     # try to close the engine properly

            wtime = 40                # wait for it, wait for it...
            while self.process.poll() is None and wtime > 0:
                time.sleep(0.05)
                wtime -= 1

            if self.process.poll() is None:  # nope, no luck
                sys.stderr.write("INFO: the engine %s won't close properly.\n" % self.exe)
                self.process.kill()
                self.process.terminate()

            self.pid = None

No sure if I've broken anything, my python is retarded. 😱

@lukasmonk
Copy link
Owner

I like the solution.
It is included in my copy.
Thank you very much.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants