Skip to content

Instantly share code, notes, and snippets.

@laser
Last active August 29, 2015 14:01
Show Gist options
  • Save laser/af20a214fbc53a3c6264 to your computer and use it in GitHub Desktop.
Save laser/af20a214fbc53a3c6264 to your computer and use it in GitHub Desktop.
Batch Client - Python
#!/usr/bin/env python
import barrister
trans = barrister.HttpTransport("http://localhost:3000/v1/todos")
client = barrister.Client(trans)
batch = client.start_batch()
batch.TodoManager.createTodo({ "title" : "Call Mom", "completed" : False })
batch.TodoManager.createTodo({ "title" : "Call Dad", "completed" : False })
batch.TodoManager.createTodo({ "title" : "Wash car", "completed" : False })
batch.TodoManager.createTodo({ "title" : "Eat Ham", "completed" : False })
results = batch.send()
for res in results:
# either res.error or res.result will be set
if res.error:
# res.error is a barrister.RpcException, so you can raise it if desired
print "err.code=%d" % res.error.code
else:
# result from a successful call
print res.result
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment