Skip to content

Commit

Permalink
Merge pull request #161 from hautof/dev-3.0.0
Browse files Browse the repository at this point in the history
fix block issue #160
  • Loading branch information
tsbxmw authored Apr 23, 2019
2 parents 75259df + 163f2bc commit fbc8066
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 17 deletions.
5 changes: 4 additions & 1 deletion haf/common/log.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,10 @@ def write_local_logger(self, msg):
self.log_output(msg_now, msg)
dir = f"./data/log/"
if not os.path.exists(dir):
os.makedirs(dir)
try:

This comment has been minimized.

Copy link
@tsbxmw

tsbxmw Apr 23, 2019

Author Collaborator

此处应该加 进程锁 Lock

1,process1 没有发现 dir
2,process2 没有发现 dir
3,process1 创建 dir
4,Process2 创建 dir 失败

os.makedirs(dir)
except Exception as error:
pass
full_name = f"{dir}/log.log"
try:
with open(full_name, 'a+') as f:
Expand Down
2 changes: 1 addition & 1 deletion haf/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@
# version define
MAIN_VERSION = 2
SUB_VERSION = 8
FIX_VERSION = 6
FIX_VERSION = 7
VERSION_TYPE = "haf"
PLATFORM_VERSION = f"{VERSION_TYPE}-{MAIN_VERSION}.{SUB_VERSION}.{FIX_VERSION}"

Expand Down
11 changes: 8 additions & 3 deletions haf/loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ def run(self):
if self.args.nout:
cb = ChargingBar(max=100)
complete_case_count = 0

show_count = []

This comment has been minimized.

Copy link
@tsbxmw

tsbxmw Apr 23, 2019

Author Collaborator

make the logger.debug only display one time when the check already have

all_count = []
# check the params
while True:
temp = self.get_parameter()
Expand All @@ -68,6 +69,8 @@ def run(self):
while True:
if not self.case_count.empty():
complete_case_count = self.case_count.get()
if complete_case_count not in all_count:
all_count.append(complete_case_count)
else:
pass
if self.args.nout:
Expand All @@ -79,7 +82,9 @@ def run(self):
self.put_case("case", None, self.case_back_queue.get())

if self.case_queue.empty() and self.case_back_queue.empty():
logger.debug(f"complete case count check here {complete_case_count} == {self.true_case_count}", __name__)
if complete_case_count not in show_count:
logger.debug(f"complete case count check here {complete_case_count} == {self.true_case_count}", __name__)
show_count.append(complete_case_count)
if complete_case_count==self.true_case_count:
if self.args.nout:
cb.finish()
Expand Down Expand Up @@ -199,7 +204,7 @@ def put_web_message(self, key: str, lock=None):

def put_case(self, key: str, lock, case):
'''
put case to case queue, from loadert to runners
put case to case queue, from loader to runners
:param key:
:param lock:
:param case:
Expand Down
21 changes: 9 additions & 12 deletions haf/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,17 +86,18 @@ def put_result(self, key: str, lock: m_lock=None, result: HttpApiResult=HttpApi
logger.info(f"{self.key} : runner {self.pid} put result {result.case.ids.id}.{result.case.ids.subid}.{result.case.ids.name}", __name__)
self.result_handler_queue.put(result)

@locker
def put_web_message(self, key: str, lock: m_lock=None):
'''
put web message to web server
:param key:
:param lock:
:return:
'''
if self.web_queue.full():
self.web_queue.get()
self.web_queue.put(self.runner)

This comment has been minimized.

Copy link
@tsbxmw

tsbxmw Apr 23, 2019

Author Collaborator

change to new locker :
1, before is all lock function
2, now just lock the get/put from/to queen

with new_locker(self.bus_client, key, lock):
if self.web_queue.full():
self.web_queue.get()
self.web_queue.put(self.runner)

def put_case_back(self, key:str, case):
'''
Expand Down Expand Up @@ -190,21 +191,17 @@ def run(self):
if not self.case_handler_queue.empty() :
with new_locker(self.bus_client, "case_runner", self.locks[0]):
case = self.case_handler_queue.get()
logger.debug(f"get case from loader {case}", __name__)
if isinstance(case, SignalTemp) and case.signal == SIGNAL_CASE_END:
case_end = True
if isinstance(case, HttpApiCase):
cases.append(case)

elif isinstance(case, (AppCase, PyCase, WebCase)):
elif isinstance(case, (HttpApiCase, AppCase, PyCase, WebCase)):
cases.append(case)

logger.debug(f"cases' length is {len(cases)}, and end is {case}", __name__)

if len(cases) > 0 and (len(cases) >= 10 or case_end or self.signal.signal):
logger.debug(f"cases' length is {len(cases)}", __name__)
if len(cases) > 0 and (len(cases) >= 1 or case_end or self.signal.signal):
logger.debug(f"cases' length is {len(cases)}, case_end is {case_end}, signal is {self.signal.signal}", __name__)
self.run_loop(cases)
cases = []

if case_end:
break
time.sleep(0.01)
Expand Down

0 comments on commit fbc8066

Please sign in to comment.