Skip to content

Instantly share code, notes, and snippets.

@gomezgoiri
Created January 27, 2016 16:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gomezgoiri/fba21334c8f74db4c154 to your computer and use it in GitHub Desktop.
Save gomezgoiri/fba21334c8f74db4c154 to your computer and use it in GitHub Desktop.
Creation of instances for pt-instances-management
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import time
import requests
from humanfriendly import Spinner, Timer
instances_to_create = 50
url = 'http://anon.kmi.open.ac.uk/instances'
response_count = {}
with Spinner(label="Creating instances", total=instances_to_create) as spinner:
progress = 0
for progress in range(instances_to_create):
r = requests.post(url)
if r.status_code not in response_count:
response_count[r.status_code] = 1
else:
response_count[r.status_code] += 1
if r.status_code!=200:
time.sleep(2.0) # Let's give a break to the server.
spinner.step(progress+1)
print response_count
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment