This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Delay interpreter startup phase until script is read
Type: behavior Stage: resolved
Components: Interpreter Core Versions: Python 3.1, Python 3.2, Python 3.3, Python 3.4, Python 3.5, Python 2.7, Python 2.6
process
Status: closed Resolution: rejected
Dependencies: Superseder:
Assigned To: Nosy List: christian.heimes, neologix, serhiy.storchaka, techtonik
Priority: normal Keywords:

Created on 2012-12-20 05:55 by techtonik, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
sub_race_removal.py techtonik, 2012-12-20 05:55
Messages (4)
msg177800 - (view) Author: anatoly techtonik (techtonik) Date: 2012-12-20 05:55
Currently, when interpreter is launched it returns immediately to parent process without waiting to read the entrypoint script. This causes problem when you need to remove this script after executing.

Is it possible to delay return to child process until the entrypoint script is read?

See test case in attach.
msg177803 - (view) Author: Charles-François Natali (neologix) * (Python committer) Date: 2012-12-20 08:17
I may be missing something, but nothing's wrong here.
When you start a subprocess, the child process keeps running (in background).

If you want to wait for its termination, just use p.wait() or p.communicate().
msg177805 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2012-12-20 08:54
You should use some kind of inter-process communication to synchronize your processes.

In particular, for get rid of a temporary script file you can either send script via pipe:

    p = Popen([sys.executable], stdin=PIPE)
    p.stdin.write(longscript)

or use it as a program argument:

    p = Popen([sys.executable, '-c', longscript])
msg177821 - (view) Author: Christian Heimes (christian.heimes) * (Python committer) Date: 2012-12-20 13:59
That's the way fork() and the subprocess module work. Please follow Serhiy's advice.
History
Date User Action Args
2022-04-11 14:57:39adminsetgithub: 60938
2012-12-20 13:59:07christian.heimessetstatus: open -> closed

type: behavior

nosy: + christian.heimes
messages: + msg177821
resolution: rejected
stage: resolved
2012-12-20 08:54:32serhiy.storchakasetnosy: + serhiy.storchaka
messages: + msg177805
2012-12-20 08:17:45neologixsetnosy: + neologix
messages: + msg177803
2012-12-20 05:55:26techtonikcreate