aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xtests/wqueue2.py16
1 files changed, 13 insertions, 3 deletions
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: