[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.python

Py2exe - Bad File Descriptor

T

2/28/2010 6:35:00 PM

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?
5 Answers

Dennis Lee Bieber

2/28/2010 8:48:00 PM

0

On Sun, 28 Feb 2010 10:35:23 -0800 (PST), T <misceverything@gmail.com>
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
wlfraed@ix.netcom.com HTTP://wlfraed.home.netcom.com/

T

2/28/2010 9:22:00 PM

0

On Feb 28, 3:48 pm, Dennis Lee Bieber <wlfr...@ix.netcom.com> wrote:
> On Sun, 28 Feb 2010 10:35:23 -0800 (PST), T <misceveryth...@gmail.com>
> 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...@ix.netcom.com      HTTP://wlfraed.home.netcom.com/

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!

Dennis Lee Bieber

3/1/2010 3:00:00 AM

0

On Sun, 28 Feb 2010 13:22:19 -0800 (PST), T <misceverything@gmail.com>
declaimed the following in gmane.comp.python.general:

> 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...
--
Wulfraed Dennis Lee Bieber KD6MOG
wlfraed@ix.netcom.com HTTP://wlfraed.home.netcom.com/

T

3/2/2010 12:42:00 AM

0

On Feb 28, 10:00 pm, Dennis Lee Bieber <wlfr...@ix.netcom.com> wrote:
> On Sun, 28 Feb 2010 13:22:19 -0800 (PST), T <misceveryth...@gmail.com>
> declaimed the following in gmane.comp.python.general:
>
> > 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...
> --
>         Wulfraed         Dennis Lee Bieber               KD6MOG
>         wlfr...@ix.netcom.com      HTTP://wlfraed.home.netcom.com/

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.

Dennis Lee Bieber

3/2/2010 9:04:00 AM

0

On Mon, 1 Mar 2010 16:41:57 -0800 (PST), T <misceverything@gmail.com>
declaimed the following in gmane.comp.python.general:

> 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.
--
Wulfraed Dennis Lee Bieber KD6MOG
wlfraed@ix.netcom.com HTTP://wlfraed.home.netcom.com/