[New-bugs-announce] [issue9503] print statement hangs Windows service

rgpitts report at bugs.python.org
Wed Aug 4 09:34:16 CEST 2010

New submission from rgpitts <richard.pitts at cdl.co.uk>:

OS: Windows 2003 Server R2 x64 Standard Edition
Python: 2.6.5
MSVC: 9.0
Application Description: Windows service calling Python C API to run algorithm written in Python.

I've been encountering a random application hang when calling the Python C API function PyObject_CallMethod to call a function on a class instance. I've discovered that the C function fwrite in string_print in stringobject.c is blocking after being called multiple times due to print statements in Python code. My application as a Windows service does not have a stdout and fwrite is buffering data before attempting to write it to a non-existent stdout, thus blocking and hanging the service. This isn't an issue when the application has a console window because stdout is available.

We are in the process changing the print statements to write to file. Ideally a Python exception needs raising if print cannot write to stdout.

components: Interpreter Core
messages: 112768
nosy: rgpitts
priority: normal
severity: normal
status: open
title: print statement hangs Windows service
type: behavior
versions: Python 2.6

Python tracker <report at bugs.python.org>

More information about the New-bugs-announce mailing list