Last active
February 3, 2016 18:17
-
-
Save ScottSturdivant/442e8a1ce49baa43995b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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