Skip to content

Instantly share code, notes, and snippets.

@ScottSturdivant
Last active February 3, 2016 18:17
Show Gist options
  • Save ScottSturdivant/442e8a1ce49baa43995b to your computer and use it in GitHub Desktop.
Save ScottSturdivant/442e8a1ce49baa43995b to your computer and use it in GitHub Desktop.
class Client(object):
@inlineCallbacks
def login(self):
login = yield get('/login/')
self.token = login['token']
@inlineCallbacks
def poll_work(self):
while True:
msgs = yield sqs.get_messages()
if msgs:
defer.returnValue(msgs)
def process_work(self, msgs):
print("Got some work...", msgs)
if __name__ == '__main__':
client = Client()
d = client.login()
d.addCallback(lambda _: client.poll_work())
d.addCallback(client.process_work)
reactor.run()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment