python shutil.rmtree - 如何删除/设置超时?

时间:2017-02-22 07:23:03

标签: python timeout settimeout directory shutil

Python 2.7,尝试使用shutil.rmtree()删除大文件夹会产生超时。 如何设置超时或让操作运行直到完成?

File "/var/www/fat/fatsite/analysis_retention/analysis_retention_handler.py", line 29, in delete_old_analysis
    shutil.rmtree(analysis_to_delete.output_path)
  File "/usr/lib/python2.7/shutil.py", line 250, in rmtree
    os.remove(fullname)
  File "/home/fat/envs/py2.7/lib/python2.7/site-packages/rq/timeouts.py", line 51, in handle_death_penalty
    'value ({0} seconds)'.format(self._timeout))
JobTimeoutException: Job exceeded maximum timeout value (180 seconds)

谢谢

1 个答案:

答案 0 :(得分:0)

这是RQ例外。 因此,Django Admin可以在RQ可重复作业对象上设置超时。 enter image description here