in identity-resolution/notebooks/identity-graph/nepytune/benchmarks/drop_graph.py [0:0]
def worker(g, q):
c = 0
nm = threading.currentThread().name
print("Worker", nm, "started")
while True:
ready = ready_flag.wait()
if not q.empty():
work = q.get()
successful = False
while not successful:
try:
if len(work[1]) > 0:
print("[{}] {} deleting {} {}".format(c,nm,len(work[1]), work[0]))
if work[0] == "edges":
g.E(work[1]).drop().iterate()
else:
g.V(work[1]).drop().iterate()
successful = True
except:
# A concurrent modification error can occur if we try to drop an element
# that is already loacked by some other process accessing the graph.
# If that happens sleep briefly and try again.
print("{} Exception dropping some {} will retry".format(nm,work[0]))
print(sys.exc_info()[0])
print(sys.exc_info()[1])
time.sleep(1)
c += 1
q.task_done()