Merge branch '2.4.4' of ssh://git.tasktools.org/tm/task into 2.4.4
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
from __future__ import division
|
from __future__ import division, print_function
|
||||||
import os
|
import os
|
||||||
import tempfile
|
import tempfile
|
||||||
import shutil
|
import shutil
|
||||||
@@ -39,7 +39,7 @@ class Taskd(object):
|
|||||||
TASKD_NOT_LISTENING = 3
|
TASKD_NOT_LISTENING = 3
|
||||||
|
|
||||||
def __init__(self, taskd=DEFAULT_TASKD, certpath=None,
|
def __init__(self, taskd=DEFAULT_TASKD, certpath=None,
|
||||||
address="localhost"):
|
address="127.0.0.1"):
|
||||||
"""Initialize a Task server that runs in the background and stores data
|
"""Initialize a Task server that runs in the background and stores data
|
||||||
in a temporary folder
|
in a temporary folder
|
||||||
|
|
||||||
@@ -207,6 +207,8 @@ class Taskd(object):
|
|||||||
self.proc = Popen(cmd, stdout=PIPE, stderr=PIPE, stdin=DEVNULL,
|
self.proc = Popen(cmd, stdout=PIPE, stderr=PIPE, stdin=DEVNULL,
|
||||||
env=self.env)
|
env=self.env)
|
||||||
else:
|
else:
|
||||||
|
self.show_log_contents()
|
||||||
|
|
||||||
raise OSError("Taskd server is still running or crashed")
|
raise OSError("Taskd server is still running or crashed")
|
||||||
|
|
||||||
# Wait for server to listen by checking connectivity in the port
|
# Wait for server to listen by checking connectivity in the port
|
||||||
@@ -218,6 +220,8 @@ class Taskd(object):
|
|||||||
return
|
return
|
||||||
|
|
||||||
elif status == self.TASKD_NEVER_STARTED:
|
elif status == self.TASKD_NEVER_STARTED:
|
||||||
|
self.show_log_contents()
|
||||||
|
|
||||||
raise OSError("Task server was never started. "
|
raise OSError("Task server was never started. "
|
||||||
"This shouldn't happen!!")
|
"This shouldn't happen!!")
|
||||||
|
|
||||||
@@ -225,6 +229,8 @@ class Taskd(object):
|
|||||||
# Collect output logs
|
# Collect output logs
|
||||||
out, err = self.proc.communicate()
|
out, err = self.proc.communicate()
|
||||||
|
|
||||||
|
self.show_log_contents()
|
||||||
|
|
||||||
raise OSError(
|
raise OSError(
|
||||||
"Task server launched with '{0}' crashed or exited "
|
"Task server launched with '{0}' crashed or exited "
|
||||||
"prematurely. Exit code: {1}. "
|
"prematurely. Exit code: {1}. "
|
||||||
@@ -242,6 +248,8 @@ class Taskd(object):
|
|||||||
sleep(1 / tries_per_minute)
|
sleep(1 / tries_per_minute)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
|
self.show_log_contents()
|
||||||
|
|
||||||
raise OSError("Unknown running status for taskd '{0}'".format(
|
raise OSError("Unknown running status for taskd '{0}'".format(
|
||||||
status))
|
status))
|
||||||
|
|
||||||
@@ -251,6 +259,8 @@ class Taskd(object):
|
|||||||
# Collect output logs
|
# Collect output logs
|
||||||
out, err = self.proc.communicate()
|
out, err = self.proc.communicate()
|
||||||
|
|
||||||
|
self.show_log_contents()
|
||||||
|
|
||||||
raise OSError("Task server didn't start and listen on port {0} after "
|
raise OSError("Task server didn't start and listen on port {0} after "
|
||||||
"{1} minutes. Stdout: {2!r}. Stderr: {3!r}.".format(
|
"{1} minutes. Stdout: {2!r}. Stderr: {3!r}.".format(
|
||||||
self.port, minutes, out, err))
|
self.port, minutes, out, err))
|
||||||
@@ -339,4 +349,14 @@ class Taskd(object):
|
|||||||
|
|
||||||
return parse_datafile(file)
|
return parse_datafile(file)
|
||||||
|
|
||||||
|
def show_log_contents(self):
|
||||||
|
"""Print to to STDOUT the contents of taskd.log
|
||||||
|
"""
|
||||||
|
if os.path.isfile(self.tasklog):
|
||||||
|
with open(self.tasklog) as fh:
|
||||||
|
print("#### Start taskd.log ####")
|
||||||
|
for line in fh:
|
||||||
|
print(line, end='')
|
||||||
|
print("#### End taskd.log ####")
|
||||||
|
|
||||||
# vim: ai sts=4 et sw=4
|
# vim: ai sts=4 et sw=4
|
||||||
|
|||||||
@@ -130,8 +130,8 @@ def _queue_output(arguments, pidq, outputq):
|
|||||||
"",
|
"",
|
||||||
("Unexpected exception caught during execution of taskw: '{0}' . "
|
("Unexpected exception caught during execution of taskw: '{0}' . "
|
||||||
"If you are running out-of-tree tests set USE_PATH=1 in shell "
|
"If you are running out-of-tree tests set USE_PATH=1 in shell "
|
||||||
"env before execution and add the location of the task binary to "
|
"env before execution and add the location of the task(d) binary "
|
||||||
"the PATH".format(e)),
|
"to the PATH".format(e)),
|
||||||
255)) # false exitcode
|
255)) # false exitcode
|
||||||
|
|
||||||
return
|
return
|
||||||
@@ -279,7 +279,7 @@ def get_IPs(hostname):
|
|||||||
return output
|
return output
|
||||||
|
|
||||||
|
|
||||||
def port_used(addr="localhost", port=None):
|
def port_used(addr="127.0.0.1", port=None):
|
||||||
"Return True if port is in use, False otherwise"
|
"Return True if port is in use, False otherwise"
|
||||||
if port is None:
|
if port is None:
|
||||||
raise TypeError("Argument 'port' may not be None")
|
raise TypeError("Argument 'port' may not be None")
|
||||||
@@ -304,7 +304,7 @@ def port_used(addr="localhost", port=None):
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
def find_unused_port(addr="localhost", start=53589, track=True):
|
def find_unused_port(addr="127.0.0.1", start=53589, track=True):
|
||||||
"""Find an unused port starting at `start` port
|
"""Find an unused port starting at `start` port
|
||||||
|
|
||||||
If track=False the returned port will not be marked as in-use and the code
|
If track=False the returned port will not be marked as in-use and the code
|
||||||
|
|||||||
Reference in New Issue
Block a user