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.

Author ncoghlan
Recipients Arfrever, Ben.Darnell, brett.cannon, eric.araujo, flox, georg.brandl, ncoghlan, pitrou
Date 2012-03-07.01:38:31
SpamBayes Score 1.88332e-10
Marked as misclassified No
Message-id <>
This is closely related to PEP 395, since multiprocessing currently hits the same issue in trying to figure out the correct setting for sys.argv0.

I quite like the sys.__argv__ idea for preserving the *exact* underlying command line (Alex Gaynor was recently asking for something similar to this).

In the meantime, it should be possible to work around the problem by running the affected subprocess invocations (i.e. when __main__.__package__ exists and is not empty) with something like:

    launch_template = """
    import runpy, sys
    sys.argv[:] = {argv}
    sys.path[:] = {path}
    import sys, subprocess, os.path, __main__
    main_base = os.path.basename(__main.__file__).splitext()[0]
    main_ref = __main__.__package__ + "." + main_base
    launch = launch_template.format(argv=sys.argv, path=sys.path, main=main_ref), shell=True, executable=sys.executable)
Note: the above isn't tested code, since it's an approach that only occurred to me recently and I haven't had a chance to fully explore it myself. However, if it works, we could make use of it in 2.7 and 3.2 to fix multiprocessing's current misbehaviour on Windows.
Date User Action Args
2012-03-07 01:38:34ncoghlansetrecipients: + ncoghlan, brett.cannon, georg.brandl, pitrou, eric.araujo, Arfrever, flox, Ben.Darnell
2012-03-07 01:38:34ncoghlansetmessageid: <>
2012-03-07 01:38:33ncoghlanlinkissue14208 messages
2012-03-07 01:38:31ncoghlancreate