Added blocking using threading.Lock. Optional blocking.