Project

General

Profile

Bug #5901 » multi.py

Test script to demonstrate issue - Brett Smith, 05/04/2015 08:25 PM

 
1
#!/usr/bin/env python
2

    
3
import arvados
4
import sys
5
import threading
6
import time
7

    
8
COLL_UUID = 'su92l-4zz18-wd2va9q9lnfx6ga'
9
NUM_RETRIES = 3
10

    
11
class CollectionTimer(threading.Thread):
12
    def run(self):
13
        arv = arvados.api('v1')
14
        start_time = time.time()
15
        coll = arv.collections().get(uuid=COLL_UUID).execute(num_retries=NUM_RETRIES)
16
        print "thread {} got {}-byte manifest in {:.3f} seconds".format(
17
            self.ident, len(coll['manifest_text']), time.time() - start_time)
18

    
19

    
20
threads = []
21
for tnum in range(int(sys.argv[1])):
22
    t = CollectionTimer()
23
    threads.append(t)
24
    t.start()
25
    print "started thread {}".format(t.ident)
26
for t in threads:
27
    t.join()
(2-2/3)