coding style
This commit is contained in:
parent
667dd8ffa5
commit
f4be637480
1 changed files with 7 additions and 7 deletions
14
vigil
14
vigil
|
|
@ -851,26 +851,26 @@ class _Result(Result):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
def work_loop(child_connection):
|
def work_loop(parent_connection):
|
||||||
while True:
|
while True:
|
||||||
tool, path = child_connection.recv()
|
tool, path = parent_connection.recv()
|
||||||
result = _Result(path, tool)
|
result = _Result(path, tool)
|
||||||
status, result.result = tools.run_tool_no_error(path, tool)
|
status, result.result = tools.run_tool_no_error(path, tool)
|
||||||
child_connection.send(status)
|
parent_connection.send(status)
|
||||||
|
|
||||||
|
|
||||||
class Worker:
|
class Worker:
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.parent_connection, child_connection = multiprocessing.Pipe()
|
self.child_connection, parent_connection = multiprocessing.Pipe()
|
||||||
self.process = multiprocessing.Process(
|
self.process = multiprocessing.Process(
|
||||||
target=work_loop, args=(child_connection,), daemon=True)
|
target=work_loop, args=(parent_connection,), daemon=True)
|
||||||
make_process_nicest(self.process.pid)
|
make_process_nicest(self.process.pid)
|
||||||
self.process.start()
|
self.process.start()
|
||||||
|
|
||||||
def run_tool(self, path, tool):
|
def run_tool(self, path, tool):
|
||||||
self.parent_connection.send([tool, path])
|
self.child_connection.send([tool, path])
|
||||||
return self.parent_connection.recv()
|
return self.child_connection.recv()
|
||||||
|
|
||||||
def stop(self):
|
def stop(self):
|
||||||
os.kill(self.process.pid, signal.SIGKILL)
|
os.kill(self.process.pid, signal.SIGKILL)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue