mailr17787 - /trunk/generic_fns/pipes.py


Others Months | Index by Date | Thread Index
>>   [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Header


Content

Posted by edward on October 09, 2012 - 12:59:
Author: bugman
Date: Tue Oct  9 12:59:11 2012
New Revision: 17787

URL: http://svn.gna.org/viewcvs/relax?rev=17787&view=rev
Log:
Python 2.4 and lower fix for the pipe_loop() generator method.

In these Python versions, a 'try' block with a 'finally' statement cannot 
contain 'yield'
statements!  This work around should be compatible with all Python versions.


Modified:
    trunk/generic_fns/pipes.py

Modified: trunk/generic_fns/pipes.py
URL: 
http://svn.gna.org/viewcvs/relax/trunk/generic_fns/pipes.py?rev=17787&r1=17786&r2=17787&view=diff
==============================================================================
--- trunk/generic_fns/pipes.py (original)
+++ trunk/generic_fns/pipes.py Tue Oct  9 12:59:11 2012
@@ -385,9 +385,11 @@
             else:
                 yield ds[key]
 
-    # Release the lock.
-    finally:
-        status.pipe_lock.release(sys._getframe().f_code.co_name)
+    # Release the lock (in a Python 2.4 and lower compatible way, see 
http://stackoverflow.com/questions/2339358/workaround-for-python-2-4s-yield-not-allowed-in-try-block-with-finally-clause).
+    except:
+        status.pipe_lock.release(sys._getframe().f_code.co_name)
+        raise
+    status.pipe_lock.release(sys._getframe().f_code.co_name)
 
 
 def pipe_names(bundle=None):




Related Messages


Powered by MHonArc, Updated Tue Oct 09 13:40:02 2012