diff options
author | VG <vg@devys.org> | 2016-04-08 00:29:35 +0200 |
---|---|---|
committer | VG <vg@devys.org> | 2016-04-08 00:29:35 +0200 |
commit | 1c8b8d2a5faefdf73ec9fccaf24ebbe826f21b97 (patch) | |
tree | 88cc900faecea7e51d430c6cd50bfaf1c1cc9e1e /tests | |
parent | 3d2835e1d90d4d9615f5c266943a49f1de8f619f (diff) | |
download | wqueue-1c8b8d2a5faefdf73ec9fccaf24ebbe826f21b97.tar.gz wqueue-1c8b8d2a5faefdf73ec9fccaf24ebbe826f21b97.tar.bz2 wqueue-1c8b8d2a5faefdf73ec9fccaf24ebbe826f21b97.zip |
Auto-commit on 807fe7afb37fe2cfcf15c9457d04f64fa11b7511
Diffstat (limited to 'tests')
-rwxr-xr-x | tests/wqueue2.py | 21 |
1 files changed, 6 insertions, 15 deletions
diff --git a/tests/wqueue2.py b/tests/wqueue2.py index 5340d0f..4c2cd4c 100755 --- a/tests/wqueue2.py +++ b/tests/wqueue2.py @@ -15,11 +15,10 @@ u8open = functools.partial(open, encoding='utf8') class PersistentQueue3: - def __init__(self, filename=None, loop=None): + def __init__(self, filename=None): self.queue = collections.deque() self.current_job = collections.deque() - self.event = asyncio.Event(loop=loop) - self.loop = loop + self.event = asyncio.Event() self.filename = filename def push_job(self, item): @@ -98,28 +97,20 @@ async def manage_client(reader, writer): print('end of manage_client') -async def manage_jobs(): +async def jobs_runner(): jobs = PersistentQueue3(filename='queue.txt') queue = [] while True: job = await jobs.get_job() - do_the_job(job=job) - async with open('queue.txt') as f: - line = await next(f) - if not line: - # schedule new job - print('executing next scheduled job') - -def read_next_job_arg(): - with open(QUEUE_FILE, 'r') as f: - line = f.readline() + await do_the_job(job=job) + jobs.mark_job_done() def main(): print('getting event loop') loop = asyncio.get_event_loop() print('got event loop') - # loop.call_soon(test) + loop.call_soon(jobs_runner) try: os.unlink('server_sock') print('creating coro...') |