From d0139eba311c380b06ba433e31576899441591e0 Mon Sep 17 00:00:00 2001 From: "Rafael H. Schloming" Date: Thu, 27 Aug 2009 20:26:54 +0000 Subject: added make doc; modified @synchronized to preserve docstrings and argnames git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@808608 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/python/Makefile | 6 ++++++ qpid/python/qpid/messaging.py | 26 ++++++++++++++++++-------- 2 files changed, 24 insertions(+), 8 deletions(-) (limited to 'qpid/python') diff --git a/qpid/python/Makefile b/qpid/python/Makefile index 380115db41..eec4076722 100644 --- a/qpid/python/Makefile +++ b/qpid/python/Makefile @@ -46,6 +46,12 @@ $(BUILD)/%.py: %.py build: $(TARGETS) +.PHONY: doc + +doc: + @mkdir -p $(BUILD) + epydoc qpid/messaging.py -o $(BUILD)/doc --no-private --no-sourcecode --include-log + install: build install -d $(PYTHON_LIB) diff --git a/qpid/python/qpid/messaging.py b/qpid/python/qpid/messaging.py index de6063e684..6df0ef742d 100644 --- a/qpid/python/qpid/messaging.py +++ b/qpid/python/qpid/messaging.py @@ -30,7 +30,7 @@ Areas that still need work: - protocol negotiation/multiprotocol impl """ -import connection, time, socket, sys, compat +import connection, time, socket, sys, compat, inspect from codec010 import StringCodec from datatypes import timestamp, uuid4, RangedSet, Message as Message010, Serial from exceptions import Timeout @@ -45,13 +45,23 @@ log = getLogger("qpid.messaging") static = staticmethod def synchronized(meth): - def sync_wrapper(self, *args, **kwargs): - self.lock() - try: - return meth(self, *args, **kwargs) - finally: - self.unlock() - return sync_wrapper + args, vargs, kwargs, defs = inspect.getargspec(meth) + scope = {} + scope["meth"] = meth + exec """ +def %s%s: + %s + %s.lock() + try: + return meth%s + finally: + %s.unlock() +""" % (meth.__name__, inspect.formatargspec(args, vargs, kwargs, defs), + repr(inspect.getdoc(meth)), args[0], + inspect.formatargspec(args, vargs, kwargs, defs, + formatvalue=lambda x: ""), + args[0]) in scope + return scope[meth.__name__] class Lockable(object): -- cgit v1.2.1