Help: Group based synchronize decorator
Piet van Oostrum
piet at cs.uu.nl
Fri Jun 19 04:53:27 EDT 2009
>>>>> Vishal Shetye <vishal_shetye at persistent.co.in> (VS) wrote:
>VS> I want to synchronize calls using rw locks per 'group' and my implementation is similar to
>VS> except that I have my own Lock implementation.
>VS> All my synchronized functions take 'whatGroup' as param. My lock considers 'group' while deciding on granting locks through acquire.
>VS> What I could come up with is:
>VS> - decorator knows(assumes) first param to decorated functions is always 'whatGroup'
>VS> - decorator passes this 'whatGroup' argument to my lock which is used in acquire logic.
>VS> Is it ok to make such assumptions in decorator?
As long as you make sure that all decorated functions indeed adhere to
that assumption there is nothing wrong with it.
Piet van Oostrum <piet at cs.uu.nl>
URL: http://pietvanoostrum.com [PGP 8DAE142BE17999C4]
Private email: piet at vanoostrum.org
More information about the Python-list