Race-condition creating folder in Python

后端 未结 5 1909
清酒与你
清酒与你 2021-01-04 02:20

I have a urllib2 caching module, which sporadically crashes because of the following code:

if not os.path.exists(self.cache_location):
    os.mkdir(self.cach         


        
5条回答
  •  隐瞒了意图╮
    2021-01-04 02:50

    When you have race conditions often EAFP(easier to ask forgiveness than permission) works better that LBYL(look before you leap)

    Error checking strategies

提交回复
热议问题