mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
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:
parent
884b721916
commit
c2428b3d09
@ -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__
|
||||||
|
Loading…
x
Reference in New Issue
Block a user