Index: trunk/absroot/source/abspy/test/threading/file.py =================================================================== diff --git a/trunk/absroot/source/abspy/test/threading/file.py b/trunk/absroot/source/abspy/test/threading/file.py new file mode 10644 --- /dev/null (revision 0) +++ b/trunk/absroot/source/abspy/test/threading/file.py (revision 123) @@ -0,0 +1,2 @@ +import sys +sys.path.insert(0,'/home/redes/workspace/absroot/source/abspy/abscontrol') \ No newline at end of file Index: trunk/absroot/source/abspy/test/threading/test1.py =================================================================== diff --git a/trunk/absroot/source/abspy/test/threading/test1.py b/trunk/absroot/source/abspy/test/threading/test1.py new file mode 10644 --- /dev/null (revision 0) +++ b/trunk/absroot/source/abspy/test/threading/test1.py (revision 123) @@ -0,0 +1,22 @@ +import Queue +import threading + +def basic_worker(queue): + while True: + item = queue.get() + # do_work(item) + print(item) + queue.task_done() +def basic(): + # http://docs.python.org/library/queue.html + queue = Queue.Queue() + for i in range(3): + t = threading.Thread(target=basic_worker,args=(queue,)) + t.daemon = True + t.start() + for item in range(4): + queue.put(item) + queue.join() # block until all tasks are done + print('got here') + +basic() \ No newline at end of file Index: trunk/absroot/source/abspy/test/threading/test2.py =================================================================== diff --git a/trunk/absroot/source/abspy/test/threading/test2.py b/trunk/absroot/source/abspy/test/threading/test2.py new file mode 10644 --- /dev/null (revision 0) +++ b/trunk/absroot/source/abspy/test/threading/test2.py (revision 123) @@ -0,0 +1,33 @@ +import threading +import time +import file +from client3 import * +from server3 import * + +def f(): + print("get_samples") + cmd = "ANST" + datarpta2 = absObj.getControlModuleStatus(cmd = cmd) + + fobj = open("monitoreo.txt","a") + fobj.write(datarpta2) + fobj.close() + threading.Timer(30, f).start() + +if __name__ == '__main__': + +# absObj = ABSServer(ipDestino="10.10.10.97",rx_buffer = "1") # Adding the same parameter to all the commands + absObj = ABSServer(ipDestino="192.168.1.117",rx_buffer = "1") # Adding the same parameter to all the commands + cmd = "NTST" + datarpta1 = absObj.getConnectionStatus(cmd = cmd) + + fobj = open("monitoreo.txt","w") + fobj.write("Monitoring\n") + fobj.write("----------\n") + fobj.close() + + f() + while 1: + pass + + \ No newline at end of file Index: trunk/absroot/source/abspy/test/threading/test3.py =================================================================== diff --git a/trunk/absroot/source/abspy/test/threading/test3.py b/trunk/absroot/source/abspy/test/threading/test3.py new file mode 10644 --- /dev/null (revision 0) +++ b/trunk/absroot/source/abspy/test/threading/test3.py (revision 123) @@ -0,0 +1,8 @@ +import threading as test +import time + +def hello(): + print "hello, world" + +t = test.Timer(1.0, hello) +t.start() # after 30 seconds, "hello, world" will be printed \ No newline at end of file