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


Python Store.delete方法代码示例

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


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

示例1: print

# 需要导入模块: from store import Store [as 别名]
# 或者: from store.Store import delete [as 别名]
print("Time Per Allocaiton (s): " + str(avg_time / store.count))

# Measure time to read
avg_time = 0
for k in keys:
    start = time.time()
    tmp = store.get(k)
    end = time.time()
    avg_time += (end - start)
print("Time Per Read (s): " + str(avg_time / store.count))

# Measure time to remove
avg_time = 0
for k in keys:
    start = time.time()
    store.delete(k)
    end = time.time()
    avg_time += (end - start)
print("Time Per Delete (s): " + str(avg_time / len(keys)))

#
# Testing API service
#

print("Testing API service, persistent connection, no concurrency")
client = storeClient.StoreClient()
client.connect()

# Service/API Put time to test
avg_time = 0
times = []
开发者ID:cnocito,项目名称:keyvaluestore,代码行数:33,代码来源:testSpeed.py

示例2: __init__

# 需要导入模块: from store import Store [as 别名]
# 或者: from store.Store import delete [as 别名]
class KvPaxosServer:
  def __init__(self):
    with open(str(ME) + 'log.txt', 'w') as file:
      file.write('log:\n')
    self.px = Paxos.make(HOSTS_LIST, ME)
    self.http_server = BaseHTTPServer.HTTPServer(
        (HOST, int(PORT)), MyHTTPRequestHandler)
    self.kvstore = Store()
    self.keep_running = True
    self.lock = Lock()
    
    # do not modify these 2 vars outside the execute() function
    # lock required to access these values. # maybe unnecessary 
    self.executed_paxos_no = 0
    # contains all executed operations and their return values
    self.operation_log = []
    self.processed_requestid = dict()
    
  def start(self):
    log("HTTP Server Starts - %s:%s" % (HOST, PORT))
    maintainance_thread = Thread(target=self.maintainance, name='maintainance')
    maintainance_thread.start()
    try:
      while self.keep_running:
      # self.http_server.serve_forever()
        self.http_server.handle_request()
    except KeyboardInterrupt:
      sys.exit(0)

    maintainance_thread.join()
    os._exit(0)
  
  def maintainance(self):
    while self.keep_running:
      while self.px.max() < self.executed_paxos_no and self.keep_running:
        # print 'maintainance sleep'
        time.sleep(MAX_SLEEP_TIME)
      if self.keep_running:
        # print 'maintainance execute', self.px.max(), self.executed_paxos_no
        self.execute(self.executed_paxos_no, None)    
      
  
  ''' this function is only called by the handler class, & the maintainance thread'''
  def execute(self, seq, requestid):
      
    # catch up. this ensures that operations are executed in ascending order
    while self.executed_paxos_no < seq:
      time.sleep(MAX_SLEEP_TIME)

    with self.lock:
      # print 'lock acquired ============================================================'
      # if seq < self.executed_paxos_no:
      #   # the operations is done by other threads already, check the log directly
      #   return operation_log[seq].return_value
      if self.processed_requestid.has_key(requestid):
        assert self.processed_requestid[requestid] < self.executed_paxos_no
        return self.operation_log[self.processed_requestid[requestid]].return_value
      # this request has not been executed yet, or is being executed by maintainance thread.
      while True:
        # since not executed, it cannot be forgotten
        decided, op_jstr = self.px.status(seq)
        if decided:
          break 
        else:
          # print 'waiting for decided value', seq, op_jstr
          time.sleep(MAX_SLEEP_TIME)
      op = Operation.decode(op_jstr)
      assert decided
      if self.processed_requestid.has_key(op.requestid):
        success, value = self.operation_log[self.processed_requestid[op.requestid]].return_value
      else:
        if op.op_type == 'GET':
          success, value = self.kvstore.get(op.key)
        elif op.op_type == 'INSERT':
          success, value = self.kvstore.insert(op.key, op.value)
        elif op.op_type == 'DELETE':
          success, value = self.kvstore.delete(op.key)
        elif op.op_type == 'UPDATE':
          success, value = self.kvstore.update(op.key, op.value)
      self.executed_paxos_no += 1
      # self.px.done(seq)
      op.done((success, value))
      self.operation_log += [op]
      assert (not self.processed_requestid.has_key(op.requestid)) or requestid is None
      if not self.processed_requestid.has_key(op.requestid):
        self.processed_requestid[op.requestid] = seq
      # print self.processed_requestid
        with open(str(ME) + 'log.txt', 'a') as file:
          file.write(op.encode() + '\n')# + str(self.processed_requestid) + '\n')
      return success, value
  
  def handle_shutdown(self):
    self.keep_running = False
开发者ID:Crispher,项目名称:OS2016Proj4,代码行数:95,代码来源:server.py

示例3: delete_domain

# 需要导入模块: from store import Store [as 别名]
# 或者: from store.Store import delete [as 别名]
def delete_domain(domain):
    store = Store()
    store.delete(domain)
    flash("%s deleted" % domain)
    fanout.update()
    return redirect(url("domains"))
开发者ID:tsing,项目名称:proxy-manager,代码行数:8,代码来源:domains.py

示例4: POST

# 需要导入模块: from store import Store [as 别名]
# 或者: from store.Store import delete [as 别名]
	def POST(self,id):
		from store import Store
		store = Store()
		data = json.dumps(store.delete(id))
		store.close()
		return data
开发者ID:elementalife,项目名称:img,代码行数:8,代码来源:img.py


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