Race-condition creating folder in Python

后端 未结 5 1950
清酒与你
清酒与你 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:39

    Could you catch the exception and then test whether the file exists as a directory or not?

提交回复
热议问题