Browse Source

python 2.x/3.x compatibility change

Sakis Kasampalis 13 years ago
parent
commit
2f0ae88eb1
1 changed files with 6 additions and 3 deletions
  1. 6 3
      pool.py

+ 6 - 3
pool.py

@@ -25,14 +25,17 @@ class qObj():
             self._q.put(self.o)           
             self.o = None   
 
-if __name__ == "__main__":   
-    import Queue    
+if __name__ == "__main__":
+    try:
+        import queue as Queue
+    except:                     # python 2.x compatibility
+        import Queue
 
     def testObj(Q):       
         someObj = qObj(Q, True)        
         print('Inside func: {}'.format(someObj.o))    
 
-    aQ = Queue.Queue()    
+    aQ = Queue.Queue()
     aQ.put("yam")    
 
     with qObj(aQ) as obj: