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


Python SUBSCRIPTION_MANAGER.destroy方法代码示例

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


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

示例1: cancel_batch_async

# 需要导入模块: from mpx.service.subscription_manager import SUBSCRIPTION_MANAGER [as 别名]
# 或者: from mpx.service.subscription_manager.SUBSCRIPTION_MANAGER import destroy [as 别名]
 def cancel_batch_async(self, sessionID):
   if self._subscriptions.has_key(sessionID):
       try:
         subscription = self._subscriptions[sessionID]
         del self._subscriptions[sessionID]
         del self._qualified_method_list[sessionID]
         del self._services[sessionID]
         del self._methods[sessionID]
         SUBSCRIPTION_MANAGER.destroy(subscription)
       except:
         msglog.log('RNA_XMLRPC_Handler',msglog.types.WARN,
                    "Error destroying subscription %r." % (subscription,))
         msglog.exception()
   return
开发者ID:mcruse,项目名称:monotone,代码行数:16,代码来源:rna_xmlrpc.py

示例2: nodebrowser_handler

# 需要导入模块: from mpx.service.subscription_manager import SUBSCRIPTION_MANAGER [as 别名]
# 或者: from mpx.service.subscription_manager.SUBSCRIPTION_MANAGER import destroy [as 别名]
 def nodebrowser_handler(self, nb, path, node, node_url):
     # the purpose of this special handler is to get all the points in 
     # one subscription instead of individually.  This greatly speeds up
     # the rz net peer driver
     sid = None
     html = ''
     if len(self.children_names()):
         node_table = {}
         for c in self.children_nodes(): #pre AML
             if isinstance(c, PointNode):
                 node_table[id(c)]=c
         if len(node_table):
             sid = SM.create_polled(node_table)
     try:
         html = nb.get_default_view(node, node_url)
     finally:
         if sid:
             SM.destroy(sid)
     return html
开发者ID:mcruse,项目名称:monotone,代码行数:21,代码来源:points.py

示例3: resync

# 需要导入模块: from mpx.service.subscription_manager import SUBSCRIPTION_MANAGER [as 别名]
# 或者: from mpx.service.subscription_manager.SUBSCRIPTION_MANAGER import destroy [as 别名]
 def resync(self):
     try:
         print 'resync'
         new_sheet = self.get_sheet()
         #subscribe to nodes that need to be read
         sub_dict = {} #dictionary to create subscriptions
         for row_index in new_sheet.keys():
             url, mode, value = new_sheet[row_index]
             if mode < 3: #need to subscribe to non-write-only
                 sub_dict[row_index] = url
             #for nodes that need to be set from values in the spreadsheet
             if mode == 2 or mode == 3: #need to set
                 try:
                     as_node(url).set(value) #value is a string or None
                 except:
                     msglog.exception()
         self.sheet = new_sheet
         if sub_dict: #create a new subscription then delete the old one
             sid = SM.create_polled(sub_dict)
             if self.sid:
                 SM.destroy(self.sid)
             self.sid = sid
             sub_dict = SM.poll_all(sid)
             self.node_values = sub_dict
             #update the spread sheet
             for row_index in sub_dict.keys():
                 url, mode, value = new_sheet[row_index]
                 if mode == 0 or mode == 1: #need to write
                     try:
                         self.set_cell(row_index, 3, sub_dict[row_index]['value']) 
                     except:
                         msglog.exception()
         #the spreadsheet and mediator should now be in sync
         self.scan()
     except:
         msglog.exception()
开发者ID:mcruse,项目名称:monotone,代码行数:38,代码来源:spreadsheet.py

示例4: test_destroy_batch

# 需要导入模块: from mpx.service.subscription_manager import SUBSCRIPTION_MANAGER [as 别名]
# 或者: from mpx.service.subscription_manager.SUBSCRIPTION_MANAGER import destroy [as 别名]
 def test_destroy_batch(self):
     sids = []
     for i in range(2):
         # BatchNodes change "really fast."
         sid = SUBSCRIPTION_MANAGER.create_polled(self.nrtB10)
         # Make sure it comes up.
         t1 = time.time()
         self.__values_changing(sid)
         sids.append(sid)
     # Double check the values are changing.
     for sid in sids:
         self.__values_changing(sid)
     # Now nuke one of the suscriptions and see that the other stays valid.
     sid = sids.pop(0)
     SUBSCRIPTION_MANAGER.destroy(sid)
     try:
         SUBSCRIPTION_MANAGER.destroy(sid)
     except ENoSuchSubscription:
         pass
     else:
         raise "No such subscription not detected."
     # Make sure that the other subscription is valid.
     sid = sids.pop(0)
     self.__values_changing(sid)
     if len(SUBSCRIPTION_MANAGER.diag_get_mnrs()) != 10:
         raise (
             "Bogus test, there should be 10 mnr at this point, not %r." %
             len(SUBSCRIPTION_MANAGER.diag_get_mnrs()))
     if len(SUBSCRIPTION_MANAGER.diag_get_mnbs()) != 1:
         raise (
             "Bogus test, there should be 1 mnb at this point, not %r." %
             len(SUBSCRIPTION_MANAGER.diag_get_mnbs()))
     SUBSCRIPTION_MANAGER.destroy(sid)
     # Make sure that the mnr is removed when the last snr is deleted.
     if len(SUBSCRIPTION_MANAGER.diag_get_mnrs()) != 0:
         raise (
             "There should not be any mnrs at this point,"
             " but there are %r." %
             len(SUBSCRIPTION_MANAGER.diag_get_mnrs()))
     # Finally, make sure that the mnb is removed when the last mnr is
     # deleted.
     if len(SUBSCRIPTION_MANAGER.diag_get_mnbs()) != 0:
         raise (
             "There should not be any mnbs at this point,"
             " but there are %r." %
             len(SUBSCRIPTION_MANAGER.diag_get_mnbs()))
     return
开发者ID:mcruse,项目名称:monotone,代码行数:49,代码来源:_test_case_subscription_manager.py

示例5: stop

# 需要导入模块: from mpx.service.subscription_manager import SUBSCRIPTION_MANAGER [as 别名]
# 或者: from mpx.service.subscription_manager.SUBSCRIPTION_MANAGER import destroy [as 别名]
 def stop(self):
     CompositeNode.stop(self)
     if self._smid:
         SM.destroy(self._smid)
         self._smid = None
开发者ID:mcruse,项目名称:monotone,代码行数:7,代码来源:bacnet_scheduler.py

示例6: invoke_batch_async

# 需要导入模块: from mpx.service.subscription_manager import SUBSCRIPTION_MANAGER [as 别名]
# 或者: from mpx.service.subscription_manager.SUBSCRIPTION_MANAGER import destroy [as 别名]
  def invoke_batch_async(self, sessionID, *qualified_method_list):
    subscription = None
    if not self.manager().validate(sessionID, touch=1):
      if self._subscriptions.has_key(sessionID):
        try:
          subscription = self._subscriptions[sessionID]
          del self._subscriptions[sessionID]
          del self._qualified_method_list[sessionID]
          del self._services[sessionID]
          del self._methods[sessionID]
          SUBSCRIPTION_MANAGER.destroy(subscription)
        except:
          msglog.log('RNA_XMLRPC_Handler',msglog.types.WARN,
                     "Error destroying subscription %r on stale session %r." %
                     (subscription, sessionID))
          msglog.exception()
      raise EInvalidSession('Invalid session')

    if self._subscriptions.has_key(sessionID):
      subscription = self._subscriptions[sessionID]
      if (self._qualified_method_list[sessionID] != qualified_method_list):
        # New batch, destroy the out of date subscription.
        try:
          del self._subscriptions[sessionID]
          del self._qualified_method_list[sessionID]
          del self._services[sessionID]
          del self._methods[sessionID]
          SUBSCRIPTION_MANAGER.destroy(subscription)
        except:
          msglog.log('RNA_XMLRPC_Handler',msglog.types.WARN,
                     "Error destroying previous subscription %r." %
                     (subscription,))
          msglog.exception()
        subscription = None

    if subscription is None:
      #
      # No subscription matching the batch, create one!
      # Build a node_reference_table:
      subscription_map = {}
      services = []
      methods = []
      for i in range(0,len(qualified_method_list)):
        rna = qualified_method_list[i]
        i_method = rna.rfind(':')
        if i_method == -1 or (i_method == 3 and rna[:3] == "mpx"):
          # There is no method specified.
          rna_node = rna
          rna_method = ''
        else:
          rna_node = rna[:i_method]
          rna_method = rna[i_method+1:]
        services.append(rna_node)
        methods.append(rna_method)
        if methods[i] == 'get':
          subscription_map[services[i]] = services[i]
      # Create the subscription using the genereated node_reference_table:
      subscription = SUBSCRIPTION_MANAGER.create_polled(subscription_map,
                                                        5*60.0)
      self._subscriptions[sessionID] = subscription
      self._qualified_method_list[sessionID] = qualified_method_list
      self._services[sessionID] = services
      self._methods[sessionID] = methods
      #
      # Now that we've added our node's, validate the other sessions.
      #
      validate_list = []
      validate_list.extend(self._subscriptions.keys())
      for test_session in validate_list:
        if not self.manager().validate(test_session, touch=0):
          expired = None
          try:
            expired = self._subscriptions[test_session]
            del self._subscriptions[test_session]
            del self._qualified_method_list[test_session]
            del self._services[test_session]
            del self._methods[test_session]
            SUBSCRIPTION_MANAGER.destroy(expired)
          except:
            msglog.log('RNA_XMLRPC_Handler',msglog.types.WARN,
                       "Error destroying subscription %r on stale session %r." %
                       (expired, test_session))
            msglog.exception()
    # Get all 'ready' values.
    services = self._services[sessionID]
    methods = self._methods[sessionID]
    polled_values = SUBSCRIPTION_MANAGER.poll_all(subscription)
    results = []
    for i in range(0,len(services)):
      service = services[i]
      try:
        if methods[i] == 'get':
          result = polled_values[service]
          if result is None:
              result = 'error: Waiting for update...'
          else:
              result = result['value']
          if isinstance(result,Exception):
            result = self._exception_string(result)
        else:
#.........这里部分代码省略.........
开发者ID:mcruse,项目名称:monotone,代码行数:103,代码来源:rna_xmlrpc.py

示例7: subscription_destroy

# 需要导入模块: from mpx.service.subscription_manager import SUBSCRIPTION_MANAGER [as 别名]
# 或者: from mpx.service.subscription_manager.SUBSCRIPTION_MANAGER import destroy [as 别名]
 def subscription_destroy(self, sessionID, sid):
   # Raise exception if this is not a valid session
   if not self.manager().validate(sessionID, touch=1):
     raise EInvalidSession('Invalid session')
   return SUBSCRIPTION_MANAGER.destroy(sid)
开发者ID:mcruse,项目名称:monotone,代码行数:7,代码来源:rna_xmlrpc.py


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