mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Always close inherited file descriptors in worker process
This commit is contained in:
parent
52aaef4407
commit
326dd8b335
@ -183,6 +183,12 @@ class Worker(object):
|
|||||||
args['stdout'] = _windows_null_file
|
args['stdout'] = _windows_null_file
|
||||||
args['stderr'] = subprocess.STDOUT
|
args['stderr'] = subprocess.STDOUT
|
||||||
|
|
||||||
|
if not iswindows:
|
||||||
|
# Close inherited file descriptors in worker
|
||||||
|
# On windows, this is done in the worker process
|
||||||
|
# itself
|
||||||
|
args['close_fds'] = True
|
||||||
|
|
||||||
self.child = subprocess.Popen(cmd, **args)
|
self.child = subprocess.Popen(cmd, **args)
|
||||||
if 'stdin' in args:
|
if 'stdin' in args:
|
||||||
self.child.stdin.close()
|
self.child.stdin.close()
|
||||||
|
@ -47,6 +47,11 @@ PARALLEL_FUNCS = {
|
|||||||
('calibre.ebooks.metadata.worker', 'save_book', 'notification'),
|
('calibre.ebooks.metadata.worker', 'save_book', 'notification'),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
try:
|
||||||
|
MAXFD = os.sysconf("SC_OPEN_MAX")
|
||||||
|
except:
|
||||||
|
MAXFD = 256
|
||||||
|
|
||||||
class Progress(Thread):
|
class Progress(Thread):
|
||||||
|
|
||||||
def __init__(self, conn):
|
def __init__(self, conn):
|
||||||
@ -80,7 +85,7 @@ def main():
|
|||||||
# Close open file descriptors inherited from parent
|
# Close open file descriptors inherited from parent
|
||||||
# as windows locks open files
|
# as windows locks open files
|
||||||
if iswindows:
|
if iswindows:
|
||||||
os.closerange(3, 1000)
|
os.closerange(3, MAXFD)
|
||||||
from calibre.constants import isosx
|
from calibre.constants import isosx
|
||||||
if isosx and 'CALIBRE_WORKER_ADDRESS' not in os.environ:
|
if isosx and 'CALIBRE_WORKER_ADDRESS' not in os.environ:
|
||||||
# On some OS X computers launchd apparently tries to
|
# On some OS X computers launchd apparently tries to
|
||||||
|
Loading…
x
Reference in New Issue
Block a user