mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
...
This commit is contained in:
parent
b95bcfbbe3
commit
b312adf29f
@ -563,9 +563,9 @@ class ServerLoop(object):
|
|||||||
pass
|
pass
|
||||||
for s, conn in tuple(self.connection_map.iteritems()):
|
for s, conn in tuple(self.connection_map.iteritems()):
|
||||||
self.close(s, conn)
|
self.close(s, conn)
|
||||||
end = time.time() + self.opts.shutdown_timeout
|
wait_till = time.time() + self.opts.shutdown_timeout
|
||||||
for pool in (self.plugin_pool, self.pool):
|
for pool in (self.plugin_pool, self.pool):
|
||||||
pool.stop(max(0, end - time.time()))
|
pool.stop(wait_till)
|
||||||
|
|
||||||
class EchoLine(Connection): # {{{
|
class EchoLine(Connection): # {{{
|
||||||
|
|
||||||
|
@ -60,8 +60,7 @@ class ThreadPool(object):
|
|||||||
def get_nowait(self):
|
def get_nowait(self):
|
||||||
return self.result_queue.get_nowait()
|
return self.result_queue.get_nowait()
|
||||||
|
|
||||||
def stop(self, shutdown_timeout):
|
def stop(self, wait_till):
|
||||||
end = time.time() + shutdown_timeout
|
|
||||||
for w in self.workers:
|
for w in self.workers:
|
||||||
try:
|
try:
|
||||||
self.request_queue.put_nowait(None)
|
self.request_queue.put_nowait(None)
|
||||||
@ -69,9 +68,9 @@ class ThreadPool(object):
|
|||||||
break
|
break
|
||||||
for w in self.workers:
|
for w in self.workers:
|
||||||
now = time.time()
|
now = time.time()
|
||||||
if now >= end:
|
if now >= wait_till:
|
||||||
break
|
break
|
||||||
w.join(end - now)
|
w.join(wait_till - now)
|
||||||
self.workers = [w for w in self.workers if w.is_alive()]
|
self.workers = [w for w in self.workers if w.is_alive()]
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@ -103,13 +102,12 @@ class PluginPool(object):
|
|||||||
for w in self.workers:
|
for w in self.workers:
|
||||||
w.start()
|
w.start()
|
||||||
|
|
||||||
def stop(self, shutdown_timeout):
|
def stop(self, wait_till):
|
||||||
end = time.time() + shutdown_timeout
|
|
||||||
for w in self.workers:
|
for w in self.workers:
|
||||||
if w.is_alive():
|
if w.is_alive():
|
||||||
w.plugin.stop()
|
w.plugin.stop()
|
||||||
for w in self.workers:
|
for w in self.workers:
|
||||||
left = end - time.time()
|
left = wait_till - time.time()
|
||||||
if left > 0:
|
if left > 0:
|
||||||
w.join(left)
|
w.join(left)
|
||||||
else:
|
else:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user