From 5d1b21751b056342771e69a545e842440060199d Mon Sep 17 00:00:00 2001 From: VG Date: Wed, 6 Apr 2016 21:34:34 +0200 Subject: Auto-commit on 807fe7afb37fe2cfcf15c9457d04f64fa11b7511 --- tests/wqueue2.py | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'tests') diff --git a/tests/wqueue2.py b/tests/wqueue2.py index 5858fcd..0a3791f 100755 --- a/tests/wqueue2.py +++ b/tests/wqueue2.py @@ -18,6 +18,7 @@ class PersistentJobQueue2: self.queue = deque.deque() self.current_job = deque.deque() self.event = asyncio.Event(loop=loop) + self.loop = loop def push_job(self, item): self.queue.push_right(item) @@ -39,16 +40,25 @@ class PersistentJobQueue2: assert not self.current_job.empty() self.current_job.pop() - def dump_queue(self, filename): + ''' + note: current file is not saved since it would be inconsistent if + the queue is reloaded but file has finished being processed + between. + + Thus a file being processed is considered either done if done + between dump and reload, or failed if the queue is shut down + before its end. + + The view here is we do not want to redo the work on a file, if the + wanted result is a success: do not close the queue. + ''' with u8open(filename, 'w') as f: - f.write(self.current_job.dump()) f.write(self.queue.dump()) def reload_from_filename(self, filename): with u8open(filename) as f: items = f.read().parse() - if class PersistentJobQueue: -- cgit v1.2.3