Sometime we need to access shared document, for example when our application write to a single file on multi-thread.
In this case we need to access the through locking.
This technique is useful for web crawler.
lock=threading.Lock() def writeToFile(): lock.acquire() try: //write data finally: lock.release()
0 comments:
Post a Comment