Skip to content

Commit f47c3d6

Browse files
committed
remotexec fix 6
1 parent 269d9ff commit f47c3d6

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

Doc/library/sys.rst

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2007,15 +2007,19 @@ always available. Unless explicitly noted otherwise, all variables are read-only
20072007
import sys
20082008
import tempfile
20092009

2010-
with tempfile.NamedTemporaryFile(
2011-
mode='w',
2012-
suffix='.py',
2013-
delete_on_close=False,
2014-
) as f:
2015-
f.write("print('Hello from remote!')")
2016-
f.flush()
2017-
os.chmod(f.name, 0o644) # Readable by group/other
2010+
# delete=False is required so the file persists after closing
2011+
f = tempfile.NamedTemporaryFile(mode='w', suffix='.py', delete=False)
2012+
try:
2013+
with f:
2014+
f.write("print('Hello from remote!')")
2015+
os.chmod(f.name, 0o644)
2016+
20182017
sys.remote_exec(pid, f.name)
2018+
finally:
2019+
try:
2020+
os.unlink(f.name)
2021+
except OSError:
2022+
pass
20192023

20202024
See :ref:`remote-debugging` for more information about the remote debugging
20212025
mechanism.

0 commit comments

Comments
 (0)