0

関連するコードは次のとおりです。

    @contextlib.contextmanager
    def make_temp_dir():
      temp_dir = tempfile.mkdtemp()
      yield temp_dir
      shutil.rmtree(temp_dir)

    with make_temp_dir(listing_id) as tmpdir:
      pass
      # Sometimes something in here throws an exception that gets caught higher up

わかりました、これをすべて書いて、私は今何が起こっているのか理解しています。デコレーターで作成している contextmanagerのexitメソッド実行されていますが、もちろん、ジェネレーターにフローを返しません。

では、これをどのように行うべきですか?

4

1 に答える 1