[Pcsclite-cvs-commit] r4803 - /trunk/PCSC/UnitaryTests/ThreadSafeConnect.py

rousseau at users.alioth.debian.org rousseau at users.alioth.debian.org
Tue Mar 9 14:57:37 UTC 2010


Author: rousseau
Date: Tue Mar  9 14:57:36 2010
New Revision: 4803

URL: http://svn.debian.org/wsvn/pcsclite/?sc=1&rev=4803
Log:
add more logging

Modified:
    trunk/PCSC/UnitaryTests/ThreadSafeConnect.py

Modified: trunk/PCSC/UnitaryTests/ThreadSafeConnect.py
URL: http://svn.debian.org/wsvn/pcsclite/trunk/PCSC/UnitaryTests/ThreadSafeConnect.py?rev=4803&op=diff
==============================================================================
--- trunk/PCSC/UnitaryTests/ThreadSafeConnect.py (original)
+++ trunk/PCSC/UnitaryTests/ThreadSafeConnect.py Tue Mar  9 14:57:36 2010
@@ -31,10 +31,13 @@
 MAX_ITER = 10
 
 
-def stress():
+def stress(*args):
     """
     stress method
     """
+    thread = args[0]
+    print "Starting thread:", thread
+
     hresult, hcontext = SCardEstablishContext(SCARD_SCOPE_USER)
     if hresult != SCARD_S_SUCCESS:
         raise Exception('Failed to establish context: '
@@ -45,8 +48,6 @@
         raise Exception('Failed to list readers: '
             + SCardGetErrorMessage(hresult))
 
-    print "Using reader:", readers[0]
-
     for j in range(0, MAX_ITER):
         # Connect in SCARD_SHARE_SHARED mode
         hresult, hcard, dwActiveProtocol = SCardConnect(hcontext, readers[0],
@@ -55,7 +56,8 @@
             raise Exception('Failed to SCardConnect: '
                 + SCardGetErrorMessage(hresult))
 
-        print j,
+        log = "%d:%d" % (thread, j)
+        print log,
 
         hresult = SCardDisconnect(hcard, SCARD_LEAVE_CARD)
         if hresult != SCARD_S_SUCCESS:
@@ -65,10 +67,11 @@
     print
 
     hresult = SCardReleaseContext(hcontext)
-    #print "SCardReleaseContext()", SCardGetErrorMessage(hresult)
     if hresult != SCARD_S_SUCCESS:
         raise Exception('Failed to release context: '
             + SCardGetErrorMessage(hresult))
+
+    print "Exiting thread:", thread
 
 def main():
     """
@@ -77,12 +80,16 @@
     threads = list()
 
     for i in range(0, MAX_THREADS):
-        thread = threading.Thread(target=stress)
+        thread = threading.Thread(target=stress, args=[i])
         threads.append(thread)
         thread.start()
 
     for thread in threads:
+        print "joining:", thread.getName(),
         thread.join()
+        print "joined:", thread.getName()
+
+    print "Exiting main"
 
 if __name__ == "__main__":
     main()




More information about the Pcsclite-cvs-commit mailing list