prototest.py

Test case that fails to reproduce the problem - D. Klotz, 01/16/2013 05:18 PM

Download (1.58 KB)

 
1
'''
2
Created on Jan 16, 2013
3

4
@author: dklotz
5
'''
6

    
7
import logging
8
import threading
9
import time
10
import rst
11
import rstsandbox
12
from rst.vision.HeadObject_pb2 import HeadObject
13
from rst.vision.HeadObjects_pb2 import HeadObjects
14

    
15
shutDown = False
16

    
17
heads = HeadObjects()
18

    
19
def threadFunc():
20
    print("%s running." % threading.current_thread().name)
21
    while not shutDown:
22
        len(heads.head_objects)
23
        
24
        str(heads)
25
        str(heads.head_objects)
26
        
27
        for head in heads.head_objects:
28
            str(head)
29
            if head.HasField("age"):
30
                ageClass = head.age.decided_class
31
                len(ageClass)
32
    print("%s shutting down." % threading.current_thread().name)
33

    
34
if __name__ == '__main__':
35
    # Configure the logger
36
    FORMAT = '%(asctime)-15s %(levelname)s %(pathname)s:%(lineno)s -- %(message)s'
37
    logging.basicConfig(format=FORMAT)
38
    #logging.getLogger("rsb.transport.socket.BusConnection").setLevel(logging.DEBUG)
39
    
40
    # Fill in the test object(s)
41
    for i in xrange(5):
42
        head = heads.head_objects.add()
43
        head.tracking_info.id = i
44
        if i % 2 == 0:
45
            head.age.decided_class = "Test" + str(i)
46
        
47
    #print len(heads.head_objects), heads
48
    
49
    thread1 = threading.Thread(target=threadFunc)
50
    thread2 = threading.Thread(target=threadFunc)
51
    thread3 = threading.Thread(target=threadFunc)
52
    thread4 = threading.Thread(target=threadFunc)
53
    
54
    thread1.start()
55
    thread2.start()
56
    thread3.start()
57
    thread4.start()
58
    
59
    try:
60
        while True:
61
            time.sleep(1)
62
    finally:
63
        shutDown = True