c = threading.RLock() with c: fd = datetime.datetime.strptime(fromDate, "%Y-%m-%d") fromDate = fd.strftime("%m-%d-%Y")