from collections import defaultdict
#This class represents a directed graph using adjacency list representation
class Graph:
def __init__(self,vertices):
self.V= vertices #No. of vertices
self.graph = defaultdict(list) # default dictionary to store graph
# function to add an edge to graph
def addEdge(self,u,v):
self.graph[u].append(v)
# Function that returns reverse (or transpose) of this graph
def getTranspose(self):
g = Graph(self.V)
# Recur for all the vertices adjacent to this vertex
for i in self.graph:
for j in self.graph[i]:
g.addEdge(j,i)
return g
g …Run Code Online (Sandbox Code Playgroud) 有没有办法跟踪python进程来检查文件被打开的位置。我lsof在运行过程中使用时打开了太多文件,但我不确定它们是在哪里打开的。
ls /proc/$pid/fd/ | wc -l
Run Code Online (Sandbox Code Playgroud)
我怀疑我使用的库之一可能没有正确处理文件。有没有办法准确地隔离正在打开文件的python代码中的哪一行?
在我的代码中,我使用 3rd 方库来处理数千个媒体文件,由于它们处于打开状态,我收到了错误
OSError: [Errno 24] Too many open files
Run Code Online (Sandbox Code Playgroud)
运行几分钟后。现在我知道提高打开文件的限制是一个选项,但这只会将错误推到以后的时间点。
浏览 Google 的Chubby Paper,
与锁服务一样,共识服务允许客户端即使只有一个活动客户端进程也能安全地取得进展;类似的技术已被用来减少拜占庭容错所需的状态机数量[24]。然而,假设共识服务不专门用于提供锁(这将其简化为锁服务),这种方法无法解决上述任何其他问题
他们提到 Chubby 不是共识服务,而是锁定服务,以及共识服务如何用于在节点对等点之间达成共识。
根据我的理解,我认为像 Chubby 和 Zookeeper 这样的服务用于将分布式应用程序问题(例如领导者选举、集群管理、共享资源访问)卸载到不同的应用程序(chubby/zookeeper),并且这些是基于锁的服务。在如何达成共识方面对文件/znode 进行锁定。
什么是共识服务?它们与锁定服务有何不同?
什么时候会使用它们中的任何一个?