本文整理汇总了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 = []
示例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
示例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"))
示例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