[PATCH] python2.3 with_*lock problems

John A Meinel john at arbash-meinel.com
Tue May 31 16:13:07 BST 2005


Martin Pool wrote:
> On Sun, 2005-05-29 at 23:24 -0500, John Arbash Meinel wrote:
> 

...

> 
> Given that, it's probably clearer just to rewrite it into try/finally
> blocks.  Oh well, at least now I know more about decorators.
> 

Well, I think decorators are clearer than try/finally blocks. Because
@with_readlock
def myfunc(self):

is pretty clear that you are using a read lock, I think it is even
clearer than:

def myfunc(self):
	""" Some documentation"""
	try:
		self.lock_read()
		...
	finally:
		self.unlock()

Because the later has the information kind of spread out, rather than
focused. If the 'with' syntax gets supported, that would also make a
decent syntax.

But since you don't get decorators, try/finally is probably better than
myfunc = with_readlock(myfunc)

It just messes up the indentation on a bunch of lines. No big deal.

John
=:->
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 251 bytes
Desc: OpenPGP digital signature
Url : https://lists.ubuntu.com/archives/bazaar/attachments/20050531/fa682e85/attachment.pgp 


More information about the bazaar mailing list