1. Tarek Ziadé
  2. distribute
  3. Issues
Issue #158 new

Windows console scripts break "multiprocessing" module

Brandon Rhodes
created an issue

If I declare a "[console_scripts]" entry point for the main() function of this simple Python script: {{{

!python

import multiprocessing, time

def child(): print "In child()"

def main(): print "Sleeping 10 seconds" time.sleep(10) print "Starting child process" p = multiprocessing.Process(target=child) p.start() p.join() print "Done" }}} then under Linux the script prints out: {{{ Sleeping 10 seconds Starting child process In child() Done }}} However, the ".exe" file created for the console script under Windows prints this out instead: {{{ Sleeping 10 seconds Starting child process Sleeping 10 seconds Starting child process Sleeping 10 seconds Starting child process Sleeping 10 seconds Starting child process .... }}} and so on forever, starting an unbounded number of processes. Clearly, the mechanism used by "multiprocessing" to start up a subordinate process under Windows using the same interpreter as is running the main process fails when confronted with a console script; instead, it just keeps running the "main()" logic over and over again and can never be diverted to run the "child()" function.

Either the console_script logic needs to become more sophisticated to detect when it is being run as a subordinate process by "multiprocessing", or else "multiprocessing" needs to be more intelligent in the presence of an .exe entry point. It was a toss-up but I decided to report the bug first here. :-)

Comments (0)

  1. Log in to comment