コード例 #1
0
ファイル: _wrapper.py プロジェクト: ChugR/qpid-proton
    def __init__(self, impl_or_constructor, get_context=None):
        init = False
        if callable(impl_or_constructor):
            # we are constructing a new object
            impl = impl_or_constructor()
            if impl is None:
                self.__dict__["_impl"] = impl
                self.__dict__["_attrs"] = EMPTY_ATTRS
                self.__dict__["_record"] = None
                raise ProtonException(
                    "Wrapper failed to create wrapped object. Check for file descriptor or memory exhaustion.")
            init = True
        else:
            # we are wrapping an existing object
            impl = impl_or_constructor
            pn_incref(impl)

        if get_context:
            record = get_context(impl)
            attrs = pn_void2py(pn_record_get(record, PYCTX))
            if attrs is None:
                attrs = {}
                pn_record_def(record, PYCTX, PN_PYREF)
                pn_record_set(record, PYCTX, pn_py2void(attrs))
                init = True
        else:
            attrs = EMPTY_ATTRS
            init = False
            record = None
        self.__dict__["_impl"] = impl
        self.__dict__["_attrs"] = attrs
        self.__dict__["_record"] = record
        if init: self._init()
コード例 #2
0
ファイル: _wrapper.py プロジェクト: roicostas/qpid-proton
    def __init__(self, impl_or_constructor, get_context=None):
        init = False
        if callable(impl_or_constructor):
            # we are constructing a new object
            impl = impl_or_constructor()
            if impl is None:
                self.__dict__["_impl"] = impl
                self.__dict__["_attrs"] = EMPTY_ATTRS
                self.__dict__["_record"] = None
                from proton import ProtonException
                raise ProtonException(
                    "Wrapper failed to create wrapped object. Check for file descriptor or memory exhaustion."
                )
            init = True
        else:
            # we are wrapping an existing object
            impl = impl_or_constructor
            pn_incref(impl)

        if get_context:
            record = get_context(impl)
            attrs = pn_void2py(pn_record_get(record, PYCTX))
            if attrs is None:
                attrs = {}
                pn_record_def(record, PYCTX, PN_PYREF)
                pn_record_set(record, PYCTX, pn_py2void(attrs))
                init = True
        else:
            attrs = EMPTY_ATTRS
            init = False
            record = None
        self.__dict__["_impl"] = impl
        self.__dict__["_attrs"] = attrs
        self.__dict__["_record"] = record
        if init: self._init()
コード例 #3
0
 def wrap(impl):
     if impl is None:
         return None
     else:
         record = pn_reactor_attachments(impl)
         attrs = pn_void2py(pn_record_get(record, PYCTX))
         if attrs and 'subclass' in attrs:
             return attrs['subclass'](impl=impl)
         else:
             return Reactor(impl=impl)
コード例 #4
0
 def wrap(impl):
     if impl is None:
         return None
     else:
         record = pn_reactor_attachments(impl)
         attrs = pn_void2py(pn_record_get(record, PYCTX))
         if attrs and 'subclass' in attrs:
             return attrs['subclass'](impl=impl)
         else:
             return Reactor(impl=impl)