mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-08 18:54:09 -04:00
More robust fix for auto reload when file is temporarily unavailable
This commit is contained in:
parent
da7ffcaf82
commit
ba95bf86b9
@ -6,7 +6,7 @@ from __future__ import (unicode_literals, division, absolute_import,
|
||||
__license__ = 'GPL v3'
|
||||
__copyright__ = '2015, Kovid Goyal <kovid at kovidgoyal.net>'
|
||||
|
||||
import os, sys, subprocess, signal, time
|
||||
import os, sys, subprocess, signal, time, errno
|
||||
from threading import Thread
|
||||
|
||||
from calibre.constants import islinux, iswindows, isosx
|
||||
@ -216,9 +216,14 @@ class Worker(object):
|
||||
self.clean_kill()
|
||||
try:
|
||||
compile_srv()
|
||||
except EnvironmentError:
|
||||
time.sleep(0.1)
|
||||
compile_srv() # Happens if the editor deletes and replaces a file being edited
|
||||
except EnvironmentError as e:
|
||||
# Happens if the editor deletes and replaces a file being edited
|
||||
if e.errno != errno.ENOENT or not getattr(e, 'filename', False):
|
||||
raise
|
||||
st = time.time()
|
||||
while not os.path.exists(e.filename) and time.time() - st < 3:
|
||||
time.sleep(0.01)
|
||||
compile_srv()
|
||||
self.p = subprocess.Popen(self.cmd, creationflags=getattr(subprocess, 'CREATE_NEW_PROCESS_GROUP', 0))
|
||||
|
||||
def auto_reload(log, dirs=frozenset(), cmd=None, add_default_dirs=True):
|
||||
|
Loading…
x
Reference in New Issue
Block a user