Skip to content

Commit

Permalink
Added a bunch more loggin
Browse files Browse the repository at this point in the history
  • Loading branch information
Eric van Zanten committed Feb 18, 2014
1 parent 2ba6556 commit 4b8d019
Showing 1 changed file with 38 additions and 23 deletions.
61 changes: 38 additions & 23 deletions tests.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import os
import time
import requests
from multiprocessing import Pool
import time

def runit(url):
s = requests.Session()
Expand All @@ -14,36 +13,52 @@ def runit(url):
print 'Select fields took %s seconds' % (str(end - start))
yes = 0
no = 0
timeout = 15
resp = s.get('%s/get-pair/' % url)
print resp
for i in range(12):
s.get('%s/mark-pair/' % url, params={'action': 'yes'})
s.get('%s/get-pair/' % url)
yes += 1
print 'Training: %s yes %s no' % (yes, no)
time.sleep(2)
try:
s.get('%s/mark-pair/' % url, params={'action': 'yes'}, timeout=timeout)
s.get('%s/get-pair/' % url, timeout=timeout)
yes += 1
print 'Training: %s yes %s no' % (yes, no)
time.sleep(2)
except requests.exceptions.Timeout:
return 'Marking pair #%s failed' % yes
for i in range(12):
s.get('%s/mark-pair/' % url, params={'action': 'no'})
s.get('%s/get-pair/' % url)
no += 1
print 'Training: %s yes %s no' % (yes, no)
time.sleep(2)
s.get('%s/mark-pair/' % url, params={'action': 'finish'})
start = time.time()
while True:
if s.get('%s/working/' % url).json().get('ready'):
end = time.time()
break
else:
time.sleep(3)
continue
try:
s.get('%s/mark-pair/' % url, params={'action': 'no'}, timeout=timeout)
s.get('%s/get-pair/' % url, timeout=timeout)
no += 1
print 'Training: %s yes %s no' % (yes, no)
time.sleep(2)
except requests.exceptions.Timeout:
return 'Marking pair #%s failed' % (yes + no)
try:
s.get('%s/mark-pair/' % url, params={'action': 'finish'}, timeout=timeout)
start = time.time()
print 'Deduplication started...'
except requests.exceptions.Timeout:
return 'Training finish failed'
try:
while True:
if s.get('%s/working/' % url, timeout=timeout).json().get('ready'):
end = time.time()
break
else:
time.sleep(3)
continue
except requests.exceptions.Timeout:
return 'Failed while waiting for results'
print 'Dedupe Took %s seconds' % (str(end - start))
return None

if __name__ == '__main__':
import sys
count = int(sys.argv[1])
pool = Pool(processes=count)
args = 'http://dedupe.datamade.us'
args = 'http://127.0.0.1:9999'
args_map = []
for i in range(count):
args_map.append(args)
pool.map(runit, args_map)
print pool.map(runit, args_map)

0 comments on commit 4b8d019

Please sign in to comment.