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


Python SUBSCRIPTION_MANAGER.create_polled方法代码示例

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


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

示例1: test_poll_all

# 需要导入模块: from mpx.service.subscription_manager import SUBSCRIPTION_MANAGER [as 别名]
# 或者: from mpx.service.subscription_manager.SUBSCRIPTION_MANAGER import create_polled [as 别名]
 def test_poll_all(self):
     sid = SUBSCRIPTION_MANAGER.create_polled(self.nrt1to4)
     nrt = SUBSCRIPTION_MANAGER.node_reference_table(sid)
     if nrt != self.nrt1to4:
         raise "Initial node reference table mismatch."
     # Check that each invokation gets all values.
     for i in range(0,10):
         all_values = SUBSCRIPTION_MANAGER.poll_all(sid)
         if len(all_values) != len(self.nrt1to4):
             # We did not get all 4 values!
             raise (
                 "poll_all(self.nrt1to4) did not return all values."
                 " (%d out of %d)" % (len(all_values),len(self.nrt1to4))
                 )
     # Check that (eventually) all the values are result dictionaries.
     all_values = SUBSCRIPTION_MANAGER.poll_all(sid)
     t1 = time.time()
     while (time.time() - t1) < 1.0:
         if None not in all_values.values():
             return
         time.sleep(0.1)
         all_values = SUBSCRIPTION_MANAGER.poll_all(sid)
     if None in all_values.values():
         raise (
             "Never got changes for all four result dictionaries, %d." %
             len(all_values)
             )
     return
开发者ID:mcruse,项目名称:monotone,代码行数:30,代码来源:_test_case_subscription_manager.py

示例2: test_timeout

# 需要导入模块: from mpx.service.subscription_manager import SUBSCRIPTION_MANAGER [as 别名]
# 或者: from mpx.service.subscription_manager.SUBSCRIPTION_MANAGER import create_polled [as 别名]
 def test_timeout(self):
     sids = []
     for i in range(2):
         if not i:
             timeout = 1.0
         else:
             timeout = None
         # ID3 is /services/time/UTC/milliseconds which should
         # change "really fast."
         sid = SUBSCRIPTION_MANAGER.create_polled({self.ID3:self.ID3},
                                                  timeout)
         # Make sure it comes up.
         t1 = time.time()
         self.__values_changing(sid)
         sids.append(sid)
     # Double check the values are changing and that the subscriptions
     # stay valid while we poll for values.
     t1 = time.time()
     while (time.time() - t1) < 2.0:
         for sid in sids:
             self.__values_changing(sid)
         time.sleep(0.1)
     # Now ensure that sid[0] times out...
     sid = sids.pop(0)
     t1 = time.time()
     while sid in SUBSCRIPTION_MANAGER.diag_get_sids():
         if (time.time()-t1) > 2.0:
             raise "%r did not timeout." % sid
         time.sleep(0.1)
     # Finally, make sure that the other subscription is valid.
     sid = sids.pop(0)
     self.__values_changing(sid)
     return
开发者ID:mcruse,项目名称:monotone,代码行数:35,代码来源:_test_case_subscription_manager.py

示例3: test_poll_all_plus_exceptions

# 需要导入模块: from mpx.service.subscription_manager import SUBSCRIPTION_MANAGER [as 别名]
# 或者: from mpx.service.subscription_manager.SUBSCRIPTION_MANAGER import create_polled [as 别名]
 def test_poll_all_plus_exceptions(self):
     SUBSCRIPTION_MANAGER._set_tunable_parameters({
         'minimum_poll_interval':0.0,
         })
     nrt1to4bad5to6 = {}
     nrt1to4bad5to6.update(self.nrt1to4)
     nrt1to4bad5to6['/services/time/is/an/illusion'] = (
         '/services/time/is/an/illusion'
         )
     nrt1to4bad5to6['/services/exception'] = '/services/exception'
     sid = SUBSCRIPTION_MANAGER.create_polled(nrt1to4bad5to6)
     nrt = SUBSCRIPTION_MANAGER.node_reference_table(sid)
     if nrt != nrt1to4bad5to6:
         raise "Initial node reference table mismatch."
     # Check that each invokation gets all values.
     for i in range(0,10):
         all_values = SUBSCRIPTION_MANAGER.poll_all(sid)
         if len(all_values) != len(nrt1to4bad5to6):
             # We did not get all 4 values!
             raise (
                 "poll_all(self.nrt1to4) did not return all values."
                 " (%d out of %d)" % (len(all_values),len(nrt1to4bad5to6))
                 )
     # Check that (eventually) all the values are result dictionaries.
     all_values = SUBSCRIPTION_MANAGER.poll_all(sid)
     t1 = time.time()
     while (time.time() - t1) < 1.0:
         if None not in all_values.values():
             self.__all_plus_exceptions_check(all_values)
             # Finally, test that a new subscription gets the correct
             # results.
             time.sleep(0.1)
             sid = SUBSCRIPTION_MANAGER.create_polled(nrt1to4bad5to6)
             time.sleep(0.1)
             all_values = SUBSCRIPTION_MANAGER.poll_all(sid)
             self.__all_plus_exceptions_check(all_values)                
             time.sleep(0.1)
             all_values = SUBSCRIPTION_MANAGER.poll_all(sid)
             self.__all_plus_exceptions_check(all_values)                
             return
         time.sleep(0.1)
         all_values = SUBSCRIPTION_MANAGER.poll_all(sid)
     if None in all_values.values():
         raise ("Never got values for all nodes: %r." % all_values)
     return
开发者ID:mcruse,项目名称:monotone,代码行数:47,代码来源:_test_case_subscription_manager.py

示例4: test_empty

# 需要导入模块: from mpx.service.subscription_manager import SUBSCRIPTION_MANAGER [as 别名]
# 或者: from mpx.service.subscription_manager.SUBSCRIPTION_MANAGER import create_polled [as 别名]
 def test_empty(self):
     sid = SUBSCRIPTION_MANAGER.create_polled(self.nrt1to4)
     nrt = SUBSCRIPTION_MANAGER.node_reference_table(sid)
     if nrt != self.nrt1to4:
         raise "Initial node reference table mismatch."
     SUBSCRIPTION_MANAGER.empty(sid)
     nrt = SUBSCRIPTION_MANAGER.node_reference_table(sid)
     if nrt != {}:
         raise "Node reference table not empty."
     return
开发者ID:mcruse,项目名称:monotone,代码行数:12,代码来源:_test_case_subscription_manager.py

示例5: test_replace

# 需要导入模块: from mpx.service.subscription_manager import SUBSCRIPTION_MANAGER [as 别名]
# 或者: from mpx.service.subscription_manager.SUBSCRIPTION_MANAGER import create_polled [as 别名]
 def test_replace(self):
     sid = SUBSCRIPTION_MANAGER.create_polled(self.nrt1to2)
     nrt = SUBSCRIPTION_MANAGER.node_reference_table(sid)
     if nrt != self.nrt1to2:
         raise "Initial node reference table mismatch."
     SUBSCRIPTION_MANAGER.replace(sid, self.nrt3to4)
     nrt = SUBSCRIPTION_MANAGER.node_reference_table(sid)
     if nrt != self.nrt3to4:
         raise "Replaced node reference table mismatch."
     return
开发者ID:mcruse,项目名称:monotone,代码行数:12,代码来源:_test_case_subscription_manager.py

示例6: test_destroy_batch

# 需要导入模块: from mpx.service.subscription_manager import SUBSCRIPTION_MANAGER [as 别名]
# 或者: from mpx.service.subscription_manager.SUBSCRIPTION_MANAGER import create_polled [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

示例7: test_poll_changed

# 需要导入模块: from mpx.service.subscription_manager import SUBSCRIPTION_MANAGER [as 别名]
# 或者: from mpx.service.subscription_manager.SUBSCRIPTION_MANAGER import create_polled [as 别名]
 def test_poll_changed(self):
     sid = SUBSCRIPTION_MANAGER.create_polled(self.nrt1to4)
     nrt = SUBSCRIPTION_MANAGER.node_reference_table(sid)
     if nrt != self.nrt1to4:
         raise "Initial node reference table mismatch."
     all_values = {}
     time.sleep(0.1)
     t1 = time.time()
     while (time.time() - t1) < 1.0:
         time.sleep(0.1)
         changed_values = SUBSCRIPTION_MANAGER.poll_changed(sid)
         all_values.update(changed_values)
         if len(all_values) == 4:
             # We got all 4 values!
             return
     raise "Never got changes for all four values, %d." % len(all_values)
     return
开发者ID:mcruse,项目名称:monotone,代码行数:19,代码来源:_test_case_subscription_manager.py

示例8: test_modify

# 需要导入模块: from mpx.service.subscription_manager import SUBSCRIPTION_MANAGER [as 别名]
# 或者: from mpx.service.subscription_manager.SUBSCRIPTION_MANAGER import create_polled [as 别名]
 def test_modify(self):
     sid = SUBSCRIPTION_MANAGER.create_polled(self.nrt1to2)
     nrt = SUBSCRIPTION_MANAGER.node_reference_table(sid)
     if nrt != self.nrt1to2:
         raise "Initial node reference table mismatch."
     SUBSCRIPTION_MANAGER.modify(sid, self.ID2, self.ID3)
     nrt = SUBSCRIPTION_MANAGER.node_reference_table(sid)
     if nrt == self.nrt1to2:
         raise "Modified node reference table not modified."
     if nrt != {self.ID1:self.ID1,self.ID2:self.ID3}:
         raise "Modified node reference table mismatch."
     try:
         SUBSCRIPTION_MANAGER.modify(sid, self.ID3, self.ID2)
     except ENoSuchNodeID:
         pass
     else:
         raise "No such NodeID not detected."
     return
开发者ID:mcruse,项目名称:monotone,代码行数:20,代码来源:_test_case_subscription_manager.py

示例9: test_add

# 需要导入模块: from mpx.service.subscription_manager import SUBSCRIPTION_MANAGER [as 别名]
# 或者: from mpx.service.subscription_manager.SUBSCRIPTION_MANAGER import create_polled [as 别名]
 def test_add(self):
     sid = SUBSCRIPTION_MANAGER.create_polled(self.nrt1to2)
     nrt = SUBSCRIPTION_MANAGER.node_reference_table(sid)
     if nrt != self.nrt1to2:
         raise "Initial node reference table mismatch."
     SUBSCRIPTION_MANAGER.add(sid, self.ID5, self.ID5)
     nrt = SUBSCRIPTION_MANAGER.node_reference_table(sid)
     nrt125 = {}
     nrt125.update(self.nrt1to2)
     nrt125[self.ID5] = self.ID5
     if nrt != nrt125:
         raise "Node reference table mismatch."
     try:
         SUBSCRIPTION_MANAGER.add(sid, self.ID5, self.ID5)
     except ENodeIDExists:
         pass
     else:
         raise "Node ID in use not detected."
     return
开发者ID:mcruse,项目名称:monotone,代码行数:21,代码来源:_test_case_subscription_manager.py

示例10: test_remove

# 需要导入模块: from mpx.service.subscription_manager import SUBSCRIPTION_MANAGER [as 别名]
# 或者: from mpx.service.subscription_manager.SUBSCRIPTION_MANAGER import create_polled [as 别名]
 def test_remove(self):
     sid = SUBSCRIPTION_MANAGER.create_polled(self.nrt1to4)
     nrt = SUBSCRIPTION_MANAGER.node_reference_table(sid)
     if nrt != self.nrt1to4:
         raise "Initial node reference table mismatch."
     SUBSCRIPTION_MANAGER.remove(sid, self.ID2)
     nrt = SUBSCRIPTION_MANAGER.node_reference_table(sid)
     nrt134 = {}
     nrt134.update(self.nrt1to4)
     del nrt134[self.ID2]
     if nrt != nrt134:
         raise "Node reference table mismatch."
     try:
         SUBSCRIPTION_MANAGER.remove(sid, self.ID2)
     except ENoSuchNodeID:
         pass
     else:
         raise "No such NodeID not detected."
     return
开发者ID:mcruse,项目名称:monotone,代码行数:21,代码来源:_test_case_subscription_manager.py

示例11: nodebrowser_handler

# 需要导入模块: from mpx.service.subscription_manager import SUBSCRIPTION_MANAGER [as 别名]
# 或者: from mpx.service.subscription_manager.SUBSCRIPTION_MANAGER import create_polled [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

示例12: resync

# 需要导入模块: from mpx.service.subscription_manager import SUBSCRIPTION_MANAGER [as 别名]
# 或者: from mpx.service.subscription_manager.SUBSCRIPTION_MANAGER import create_polled [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

示例13: subscription_create_polled

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

示例14: test_create_polled

# 需要导入模块: from mpx.service.subscription_manager import SUBSCRIPTION_MANAGER [as 别名]
# 或者: from mpx.service.subscription_manager.SUBSCRIPTION_MANAGER import create_polled [as 别名]
 def test_create_polled(self):
     sid = SUBSCRIPTION_MANAGER.create_polled()
     return
开发者ID:mcruse,项目名称:monotone,代码行数:5,代码来源:_test_case_subscription_manager.py

示例15: invoke_batch_async

# 需要导入模块: from mpx.service.subscription_manager import SUBSCRIPTION_MANAGER [as 别名]
# 或者: from mpx.service.subscription_manager.SUBSCRIPTION_MANAGER import create_polled [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


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