当前位置: 首页>>代码示例>>Python>>正文


Python weakref.ProxyType方法代码示例

本文整理汇总了Python中weakref.ProxyType方法的典型用法代码示例。如果您正苦于以下问题:Python weakref.ProxyType方法的具体用法?Python weakref.ProxyType怎么用?Python weakref.ProxyType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在weakref的用法示例。


在下文中一共展示了weakref.ProxyType方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

# 需要导入模块: import weakref [as 别名]
# 或者: from weakref import ProxyType [as 别名]
def __init__(self, parent_message):
    """Args:
      parent_message: The message whose _Modified() method we should call when
        we receive Modified() messages.
    """
    # This listener establishes a back reference from a child (contained) object
    # to its parent (containing) object.  We make this a weak reference to avoid
    # creating cyclic garbage when the client finishes with the 'parent' object
    # in the tree.
    if isinstance(parent_message, weakref.ProxyType):
      self._parent_message_weakref = parent_message
    else:
      self._parent_message_weakref = weakref.proxy(parent_message)

    # As an optimization, we also indicate directly on the listener whether
    # or not the parent message is dirty.  This way we can avoid traversing
    # up the tree in the common case.
    self.dirty = False 
开发者ID:ryfeus,项目名称:lambda-packs,代码行数:20,代码来源:python_message.py

示例2: __init__

# 需要导入模块: import weakref [as 别名]
# 或者: from weakref import ProxyType [as 别名]
def __init__(self,runner):
    """
    Param
    ----------------------------------------------------------
    runner - Instance of TaskRunner
    """
    ipc.Responder.__init__(self, inputProtocol)

    self.log=logging.getLogger("TaskRunnerResponder")

    # should we use weak references to avoid circular references?
    # We use weak references b\c self.runner owns this instance of TaskRunnerResponder
    if isinstance(runner,weakref.ProxyType):
      self.runner=runner
    else:
      self.runner=weakref.proxy(runner)

    self.task=weakref.proxy(runner.task) 
开发者ID:pluralsight,项目名称:spavro,代码行数:20,代码来源:tether_task_runner.py

示例3: __init__

# 需要导入模块: import weakref [as 别名]
# 或者: from weakref import ProxyType [as 别名]
def __init__(self, parent_message):
    """Args:
      parent_message: The message whose _Modified() method we should call when
        we receive Modified() messages.
    """




    if isinstance(parent_message, weakref.ProxyType):
      self._parent_message_weakref = parent_message
    else:
      self._parent_message_weakref = weakref.proxy(parent_message)




    self.dirty = False 
开发者ID:GoogleCloudPlatform,项目名称:python-compat-runtime,代码行数:20,代码来源:python_message.py

示例4: _recompile_physics_and_update_observables

# 需要导入模块: import weakref [as 别名]
# 或者: from weakref import ProxyType [as 别名]
def _recompile_physics_and_update_observables(self):
    """Sets up the environment for latest MJCF model from the task."""
    self._physics_proxy = None
    self._recompile_physics()
    if isinstance(self._physics, weakref.ProxyType):
      self._physics_proxy = self._physics
    else:
      self._physics_proxy = weakref.proxy(self._physics)

    if self._overridden_n_sub_steps is not None:
      self._n_sub_steps = self._overridden_n_sub_steps
    else:
      self._n_sub_steps = self._task.physics_steps_per_control_step

    self._hooks.refresh_entity_hooks()
    self._hooks.after_compile(self._physics_proxy, self._random_state)
    self._observation_updater = self._make_observation_updater()
    self._observation_updater.reset(self._physics_proxy, self._random_state) 
开发者ID:deepmind,项目名称:dm_control,代码行数:20,代码来源:environment.py

示例5: _parent

# 需要导入模块: import weakref [as 别名]
# 或者: from weakref import ProxyType [as 别名]
def _parent(self, value):
        if value is not None and not isinstance(value, weakref.ProxyType):
            value = weakref.proxy(value)
        self.__parent = value 
开发者ID:vmarkovtsev,项目名称:plueprint,代码行数:6,代码来源:entities.py

示例6: _request

# 需要导入模块: import weakref [as 别名]
# 或者: from weakref import ProxyType [as 别名]
def _request(self, value):
        if value is not None and not isinstance(value, weakref.ProxyType):
            value = weakref.proxy(value)
        self.__request = value 
开发者ID:vmarkovtsev,项目名称:plueprint,代码行数:6,代码来源:entities.py

示例7: HTTPHandlerGen

# 需要导入模块: import weakref [as 别名]
# 或者: from weakref import ProxyType [as 别名]
def HTTPHandlerGen(runner):
  """
  This is a class factory for the HTTPHandler. We need
  a factory b\c we need a reference to the runner

  Parameters
  -----------------------------------------------------------------
  runner - instance of the task runner
  """

  if not(isinstance(runner,weakref.ProxyType)):
    runnerref=weakref.proxy(runner)
  else:
    runnerref=runner

  class TaskRunnerHTTPHandler(BaseHTTPRequestHandler):
    """Create a handler for the parent.
    """

    runner=runnerref
    def __init__(self,*args,**param):
      """
      """
      BaseHTTPRequestHandler.__init__(self,*args,**param)

    def do_POST(self):
      self.responder =TaskRunnerResponder(self.runner)
      call_request_reader = ipc.FramedReader(self.rfile)
      call_request = call_request_reader.read_framed_message()
      resp_body = self.responder.respond(call_request)
      self.send_response(200)
      self.send_header('Content-Type', 'avro/binary')
      self.end_headers()
      resp_writer = ipc.FramedWriter(self.wfile)
      resp_writer.write_framed_message(resp_body)

  return TaskRunnerHTTPHandler 
开发者ID:pluralsight,项目名称:spavro,代码行数:39,代码来源:tether_task_runner.py

示例8: CheckCursorConnection

# 需要导入模块: import weakref [as 别名]
# 或者: from weakref import ProxyType [as 别名]
def CheckCursorConnection(self):
        if not isinstance(self.cur.connection, weakref.ProxyType) and \
           not isinstance(self.cur.connection, weakref.CallableProxyType):
            fail("cursor.connection doesn't return the correct type") 
开发者ID:sassoftware,项目名称:conary,代码行数:6,代码来源:api_tests.py

示例9: physics

# 需要导入模块: import weakref [as 别名]
# 或者: from weakref import ProxyType [as 别名]
def physics(self):
    """Returns a `weakref.ProxyType` pointing to the current `mjcf.Physics`.

    Note that the underlying `mjcf.Physics` will be destroyed whenever the MJCF
    model is recompiled. It is therefore unsafe for external objects to hold a
    reference to `environment.physics`. Attempting to access attributes of a
    dead `Physics` instance will result in a `ReferenceError`.
    """
    return self._physics_proxy 
开发者ID:deepmind,项目名称:dm_control,代码行数:11,代码来源:environment.py

示例10: enter

# 需要导入模块: import weakref [as 别名]
# 或者: from weakref import ProxyType [as 别名]
def enter(self, handlers, loop=None):
        assert self._loop or loop
        if loop:
            if not isinstance(loop, weakref.ProxyType):
                loop = weakref.proxy(loop)
            self._loop = loop

        if not isinstance(handlers, weakref.ProxyType):
            handlers = weakref.proxy(handlers)

        token = self.__context__.set(handlers)

        yield self
        self.__context__.reset(token) 
开发者ID:ZSAIm,项目名称:Nbdler,代码行数:16,代码来源:handler.py


注:本文中的weakref.ProxyType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。