python stdio in osx launchd
Monday, August 16, 2010
Running Python scripts via launchd doesn't seem to flush stdout print statements (ie. using the basic 'print' command). This can be confirmed by importing sys and calling sys.stdout.flush() after the print statements to see them actually output.
The solution? Add the -u flag to tell python not to buffer its stdio.
In an OSX launchd plist file, your solution may include:
<key>ProgramArguments</key>
<array>
<string>/usr/bin/python</string>
<string>-u</string>
0 comments:
Subscribe to:
Post Comments (Atom)