def get_length(self,):
""" Read the whole queue file and return the number of lines. """
try:
with open(self.file_path, 'r') as fd:
fcntl.flock(fd, fcntl.LOCK_SH)
n = 0
for _ in fd.readlines():
n += 1
fcntl.flock(fd, fcntl.LOCK_UN)
return n
except Exception:
return 0
评论列表
文章目录