From c4d61b7bfa3e3723ff87df8c163c9d77feeff4f8 Mon Sep 17 00:00:00 2001 From: VG Date: Fri, 26 Feb 2016 16:54:38 +0100 Subject: wip --- tests/wqueue.py | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/tests/wqueue.py b/tests/wqueue.py index 837fb26..528a10c 100755 --- a/tests/wqueue.py +++ b/tests/wqueue.py @@ -4,16 +4,27 @@ import fcntl import time import subprocess import os +import asyncio QUEUE_FILE = 'queue.txt' COMMAND = './command.sh' +loop = asyncio.get_event_loop() + +class JobHandler(asyncio.SubprocessProtocol): + def process_exited(self): + print() + def do_job(command=None, arg=None): assert(command) assert(arg) print('arg:', arg) print('doing operation with arg') - ret = subprocess.check_call([command, arg]) + #ret = subprocess.check_call([command, arg]) + loop.suprocess_exec([command, arg], + stdin=subprocess.DEVNULL, + stdout=sys.stdout, + stderr=sys.stderr) print('ret:', ret) return ret == 0 @@ -34,11 +45,19 @@ def pop_job_arg(): fo.write(line) os.rename(queue_tmp, queue) +def check_queue(): + #loop = asyncio.get_event_loop() + #loop.run_forever() + + #with open('queue.txt', 'w') as f: # fcntl.lockf(f, fcntl.LOCK_EX) # time.sleep(9999) -while True: - job_arg = read_next_job_arg() - if do_job(command=COMMAND, arg=job_arg): - pop_job_arg() +#while True: +# job_arg = read_next_job_arg() +# if do_job(command=COMMAND, arg=job_arg): +# pop_job_arg() + +#loop = asyncio.get_event_loop() +loop.run_forever() -- cgit v1.2.3