summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rwxr-xr-xtests/wqueue2.py21
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...')