Synchronise muti-threads in Python
问题 The class BrokenLinkTest in the code below does the following. takes a web page url finds all the links in the web page get the headers of the links concurrently (this is done to check if the link is broken or not) print 'completed' when all the headers are received. from bs4 import BeautifulSoup import requests class BrokenLinkTest(object): def __init__(self, url): self.url = url self.thread_count = 0 self.lock = threading.Lock() def execute(self): soup = BeautifulSoup(requests.get(self.url)