Windows: file operations don't always succeed as expected
まだ誰も着手していません。
評価
調査の方向性
ファイル操作を実行する try_remove_tree 関数とインストーラースクリプトについては、travis_build_script.py を参照してください。shutil.rmtree と os.remove に関する Windows 固有の競合状態を理解してください。ポーリングメカニズムをテストし、コードベース内の他のファイル操作に適用することを検討してください。
索引モデルが issue の本文から書いたものです。
説明
Problems
- shutil.rmtree or os.remove does not always ensure that files are fully removed after function returns
- remove may take multiple attempts to succeed
- mkdir(path, exist_ok=True) might have a race condition if it is called just after the folder is "removed"
Related Issues
- https://github.com/07th-mod/python-patcher/issues/33#issuecomment-489390131 "07th Mod - Install failed due to error: [WinError 145] The directory is not empty"
Description
I noticed that sometimes in travis_build_script.py, try_remove_tree() didn't always remove the file immediately (the file would exist for some time after the function was called. The function used to be defined like this:
def try_remove_tree(path):
try:
if os.path.isdir(path):
shutil.rmtree(path)
else:
os.remove(path)
except FileNotFoundError:
pass
but I changed it to this
def try_remove_tree(path):
try:
if os.path.isdir(path):
shutil.rmtree(path)
else:
os.remove(path)
except FileNotFoundError:
pass
# Make sure the folder is really removed
poll_cnt = 0
while os.path.exists(path):
print(f"Waiting for {path} to be removed ({poll_cnt})")
if poll_cnt < 5:
time.sleep(1)
else:
raise Exception(f"Folder {path} could not be removed!")
poll_cnt += 1
The # Make sure the folder is really removed did trigger on my machine (at least once), and after 1 second the file was "properly" removed.
If this behavior can happen on windows, we should also update the installer scripts, which use the same functions, to add this kind of functionality.
The installer scripts currently don't do multiple attempts when doing operations like extraction, deletion etc, so it may be worth checking for those sort of issues as well.
- 主要言語
- JavaScript
- スター
- 214
- フォーク
- 12
- PR マージ指標
- 30日以内にマージされた PR はありません
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
07th-mod/python-patcher のほかの issue
-
難易度 1/5 1時間未満 初心者へのやさしさ 75/100
07th-mod/python-patcher#214 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
07th-mod/python-patcher#193 ·
-
難易度 1/5 1時間未満 初心者へのやさしさ 75/100
07th-mod/python-patcher#137 ·
-
enhancement help wanted
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
07th-mod/python-patcher#83 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
07th-mod/python-patcher#80 · コメント 11 件 ·
07th-mod/python-patcher の issue をすべて見る
似ている issue
-
t0ggles
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
nolimits4web/swiper#8240 · コメント 1 件 ·
-
netbox status: backlog topic: testing type: housekeeping
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
netbox-community/netbox#23395 ·
メンテナーはふだん 1 日以内に返信
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
メンテナーはふだん 1 日以内に返信
-
[scanner] check:spelling skips blog/ — posts and author metadata are never spell-checked対応中かも @hivecommons-hive が今日担当しました。 オープンagent/scanner bug hive/covered-by-pr hive/hosted-available-lke648397-260827-5n31
難易度 1/5 1時間未満 初心者へのやさしさ 72/100
cncf/endusers#1452 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
Edit: HTVKey.vnオープンchannels:edit check:passed
難易度 1/5 1時間未満 初心者へのやさしさ 72/100
メンテナーはふだん 6 日以内に返信