Skip to content

Commit

Permalink
simplified coroutine
Browse files Browse the repository at this point in the history
  • Loading branch information
joamag committed Feb 5, 2017
1 parent dcbc903 commit 3f62dc5
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/colony_print/controllers/node.py
Expand Up @@ -28,7 +28,7 @@ def show(self, id):
def jobs(self, id):
self.request.set_content_type("application/json")
for value in appier.header_a(): yield value
for value in appier.ensure_a(self.gen_wait_jobs(id)): yield value
for value in self.gen_wait_jobs(id): yield value

@appier.route("/nodes/<str:id>/print", ("GET", "POST"), json = True)
@appier.ensure(token = "admin")
Expand Down Expand Up @@ -68,12 +68,11 @@ def print_printer_o(self, id, printer):
def gen_wait_jobs(self, id):

@appier.coroutine
def wait_jobs(future):
def wait_jobs():
while True:
jobs = self.owner.jobs.pop(id, [])
if jobs: break
for value in appier.wait("jobs:%s" % id): yield value
jobs_s = json.dumps(jobs)
future.set_result(jobs_s)
yield json.dumps(jobs)

return wait_jobs

0 comments on commit 3f62dc5

Please sign in to comment.