Skip to content

Commit

Permalink
Fix resource leak in Pex self-isolation. (pex-tool#1052)
Browse files Browse the repository at this point in the history
  • Loading branch information
jsirois authored Oct 1, 2020
1 parent 0a6fa57 commit cbb44f5
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion pex/third_party/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import sys
import zipfile
from collections import OrderedDict, namedtuple
from contextlib import closing


# NB: All pex imports are performed lazily to play well with the un-imports performed by both the
Expand Down Expand Up @@ -379,7 +380,8 @@ def recursive_copy(srcdir, dstdir):
recursive_copy(src_entry, dst_entry)
elif not entry_name.endswith(".pyc"):
with open(dst_entry, "wb") as fp:
shutil.copyfileobj(resource_stream(module, src_entry), fp)
with closing(resource_stream(module, src_entry)) as resource:
shutil.copyfileobj(resource, fp)

pex_path = os.path.join(vendor.VendorSpec.ROOT, "pex")
with _tracer().timed("Hashing pex"):
Expand Down

0 comments on commit cbb44f5

Please sign in to comment.