Skip to content

Commit

Permalink
Requeue abandoned metatiles.
Browse files Browse the repository at this point in the history
If a renderer unregisters itself while it's in the middle of rendering a
metatile, that metatile should be requeued on the assumption that the
renderer didn't finish it.  Since we don't know which queue it came from,
it goes into the "important" queue.
  • Loading branch information
asciipip committed Jun 24, 2014
1 parent 595d86c commit cd0dbe0
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions queuemaster.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,13 @@ def mark_metatile_rendered(self, z, x, y):
if mt in self.pending_metatiles:
self.pending_metatiles.remove(mt)

def mark_metatile_abandoned(self, z, x, y):
mt = '%s/%s/%s' % (z, x, y)
with self.lock:
if mt in self.pending_metatiles:
self.pending_metatiles.remove(mt)
self.queue_metatile(z, x, y, self.important_stack, 'abandoned')

def get_stats(self):
stats = {z: len(self.zoom_queues[z]) for z in xrange(0, self.maxz + 1)}
stats.update({'important': len(self.important_stack),
Expand Down Expand Up @@ -457,6 +464,9 @@ def add_renderer(self, message, queue):
self.renderers[queue] = Renderer(message, self.queue, queue, self.channel)

def remove_renderer(self, queue):
if self.renderers[queue].working_on:
z, x, y = [ int(s) for s in self.renderers[queue].working_on.split('/') ]
self.queue.mark_metatile_abandoned(z, x, y)
del self.renderers[queue]

def send_render_requests(self):
Expand Down

0 comments on commit cd0dbe0

Please sign in to comment.