Metaclasses, decorators, and synchronization

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Michael Ekstrand

    #1

    Metaclasses, decorators, and synchronization

    I've been googling around for a bit trying to find some mechanism for
    doing in Python something like Java's synchronized methods. In the
    decorators PEP, I see examples using a hypothetical synchronized
    decorator, but haven't stumbled across any actual implementation of
    such a decorator. I've also found Synch.py, but that seems to use
    pre-2.2 metaclasses from what I have read.

    Basically, what I want to do is something like this:

    class MyClass:
    __metaclass__ = SynchronizedMet a
    @synchronized
    def my_sync_method( ):
    pass

    where SychronizedMeta is some metaclass that implements synchronization
    logic for classes bearing some synchronized decorator (probably also
    defined by the module defining SynchronizedMet a).

    After looking in the Cheeseshop, the Python source distribution, and
    Google, I have not been able to find anything that implements this
    functionality. If there isn't anything, that's fine, I'll just write it
    myself (and hopefully be able to put it in the cheeseshop), but I'd
    rather avoid duplicating effort solving previously solved problems...
    So, does anyone know of anything that alreaady does this? (or are there
    some serious problems with my design?)

    TIA,
    Michael

Working...