def serialize(self, f):
        """
        Decorator to serialize access to a callable *f*
        """
        s = self.router()

        @self.spawn
        def _():
            for f, a, kw, r in s.recver:
                try:
                    r.send(f(*a, **kw))
                except Exception, e:
                    r.send(e)

        def _(*a, **kw):
            r = self.pipe()
            s.send((f, a, kw, r))
            return r.recv()

        return _
def serialize ( self , f ) : s = self . router ( ) @ self . spawn def _ ( ) : for f , a , kw , r in s . recver : try : r . send ( f ( * a , ** kw ) ) except Exception , e : r . send ( e ) def _ ( * a , ** kw ) : r = self . pipe ( ) s . send ( ( f , a , kw , r ) ) return r . recv ( ) return _
Decorator to serialize access to a callable *f*