better cron stopping, thanks Álvaro José Iradier
This commit is contained in:
@@ -1 +1 @@
|
|||||||
Version 2.4.2-stable+timestamp.2013.03.10.09.09.48
|
Version 2.4.2-stable+timestamp.2013.03.10.10.20.58
|
||||||
|
|||||||
+5
-1
@@ -22,6 +22,7 @@ from settings import global_settings
|
|||||||
|
|
||||||
logger = logging.getLogger("web2py.cron")
|
logger = logging.getLogger("web2py.cron")
|
||||||
_cron_stopping = False
|
_cron_stopping = False
|
||||||
|
_cron_subprocs = []
|
||||||
|
|
||||||
|
|
||||||
def absolute_path_link(path):
|
def absolute_path_link(path):
|
||||||
@@ -42,7 +43,8 @@ def stopcron():
|
|||||||
"graceful shutdown of cron"
|
"graceful shutdown of cron"
|
||||||
global _cron_stopping
|
global _cron_stopping
|
||||||
_cron_stopping = True
|
_cron_stopping = True
|
||||||
|
while _cron_subprocs:
|
||||||
|
_cron_subprocs.pop().terminate()
|
||||||
|
|
||||||
class extcron(threading.Thread):
|
class extcron(threading.Thread):
|
||||||
|
|
||||||
@@ -232,6 +234,7 @@ class cronlauncher(threading.Thread):
|
|||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
import subprocess
|
import subprocess
|
||||||
|
global _cron_subprocs
|
||||||
if isinstance(self.cmd, (list, tuple)):
|
if isinstance(self.cmd, (list, tuple)):
|
||||||
cmd = self.cmd
|
cmd = self.cmd
|
||||||
else:
|
else:
|
||||||
@@ -241,6 +244,7 @@ class cronlauncher(threading.Thread):
|
|||||||
stdout=subprocess.PIPE,
|
stdout=subprocess.PIPE,
|
||||||
stderr=subprocess.PIPE,
|
stderr=subprocess.PIPE,
|
||||||
shell=self.shell)
|
shell=self.shell)
|
||||||
|
_cron_subprocs.append(proc)
|
||||||
(stdoutdata, stderrdata) = proc.communicate()
|
(stdoutdata, stderrdata) = proc.communicate()
|
||||||
if proc.returncode != 0:
|
if proc.returncode != 0:
|
||||||
logger.warning(
|
logger.warning(
|
||||||
|
|||||||
@@ -434,6 +434,10 @@ class web2pyDialog(object):
|
|||||||
self.try_stop_scheduler(t)
|
self.try_stop_scheduler(t)
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
try:
|
||||||
|
newcron.stopcron()
|
||||||
|
except:
|
||||||
|
pass
|
||||||
try:
|
try:
|
||||||
self.server.stop()
|
self.server.stop()
|
||||||
except:
|
except:
|
||||||
|
|||||||
Reference in New Issue
Block a user