Py2exe - Bad File Descriptor

T

T

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':mad:9, 'Bad file descriptor')

Anyone have an idea what could be causing this?
 
D

Dennis Lee Bieber

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':mad: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?
 
T

T

        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?

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!
 
D

Dennis Lee Bieber

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!

True services typically don't have interactive (console) type I/O...
What is more likely to work is to have an open socket waiting for
connections, and the use of a separate user-space client that connects
to the socket...
 
T

T

        True services typically don't have interactive (console) type I/O...
What is more likely to work is to have an open socket waiting for
connections, and the use of a separate user-space client that connects
to the socket...

So how would that work..would the program buffer all the "print"
output, then send it to the client when it connects? Do you happen to
know of any available code that utilizes this method, or something
similar? Thanks for your help.
 
D

Dennis Lee Bieber

So how would that work..would the program buffer all the "print"
output, then send it to the client when it connects? Do you happen to
know of any available code that utilizes this method, or something
similar? Thanks for your help.

No... /nothing/ would be "output" unless a client were connected.

The other approach is to use a log file of some sort (or the system
log for the OS).

If you need interactive access (output and input) to a service, the
service will need to be written with a communication protocol to pass
data both ways. If all you need is output, the best means would be via a
logging scheme that doesn't depend upon consoles or log-ins.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top