Py2exe - Bad File Descriptor

T misceverything at
Sun Feb 28 22:22:19 CET 2010

On Feb 28, 3:48 pm, Dennis Lee Bieber <wlfr... at> wrote:
> On Sun, 28 Feb 2010 10:35:23 -0800 (PST), T <misceveryth... at>
> declaimed the following in gmane.comp.python.general:
> > I have a Python script, which is a Windows Service, that I created an
> > EXE of via py2exe.  As part of the program, it calls some external
> > binaries, one of which restarts the computer.  When I'm logged in,
> > this works fine.  However, if I log out, the service stops and logs
> > the following error in the Event Log:
> > <type 'exceptions.IOError'>:(9, 'Bad file descriptor')
> > Anyone have an idea what could be causing this?
>         Without code, one must play psychic... And I haven't dusted off the
> Tarot cards, I Ching coins, and Crystal balls is some time (No, I don't
> have a ouija board)...
>         Could it be you have a mapped drive that gets disconnected when you
> log off?
>         Is the service being started as part of your login?
>         Does it attempt to write to a console?
> --
>         Wulfraed         Dennis Lee Bieber               KD6MOG
>         wlfr... at      HTTP://

Sorry for the lack of code - yes, it does try to write to the
console.  From what I'm finding, this error may be due to the fact
that there is no "console" to write to when I'm logged off.  However,
I would like to be able to print to screen if I run the EXE in debug
mode (i.e. "myservice.exe debug").  Do you know of any way around
this?  Also, I need to get the output generated from an external EXE -
will subprocess.Popen cause problems if I use stdout=PIPE?  Thanks for
your help!

More information about the Python-list mailing list