Fix errors in __del__ of overseer

I can never get used to be absurd python stdlib philosophy of raising
timeouterrors on wait instead of returning None
This commit is contained in:
Kovid Goyal 2022-04-21 14:08:53 +05:30
parent 884b721916
commit c2428b3d09
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -7,6 +7,7 @@ import json
import os import os
import sys import sys
import weakref import weakref
from contextlib import suppress
from qt.core import QLoggingCategory, QUrl from qt.core import QLoggingCategory, QUrl
from threading import Lock, Thread, get_ident from threading import Lock, Thread, get_ident
@ -52,6 +53,11 @@ qt.webenginecontext.info=false
overseers = [] overseers = []
def safe_wait(w, timeout):
with suppress(Exception):
return w.wait(timeout)
class Overseer: class Overseer:
def __init__(self): def __init__(self):
@ -90,10 +96,10 @@ class Overseer:
w.stdin.write(b'EXIT:0\n') w.stdin.write(b'EXIT:0\n')
w.stdin.flush() w.stdin.flush()
for w in self.workers.values(): for w in self.workers.values():
if w.wait(0.2) is None: if safe_wait(w, 0.2) is None:
w.terminate() w.terminate()
if not iswindows: if not iswindows:
if w.wait(0.1) is None: if safe_wait(w, 0.1) is None:
w.kill() w.kill()
self.workers.clear() self.workers.clear()
close = __del__ close = __del__