Unix Programming - IOERROR Broken Pipe

This is Interesting: Free IT Magazines  
Home > Archive > Unix Programming > September 2004 > IOERROR Broken Pipe





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author IOERROR Broken Pipe
Ruben

2004-09-16, 11:16 am

I am reading a large text file a chunk at a time using the
readlines(buffer_size) statement. I get an IOERROR ERRNO 32 Broken
Pipe command when I "pipe" the output to mysql database using the
following command:

python script.py | mysql

I am using RED HAT 9 Linux. The problem only happens if I use the pipe
to MYSQL. It breaks but it gets to process around 1000 MYSQL
statements.

If I only use the following statement:

python script.py

The programs runs ok and reads all text records without problems. I
do need to sent the pipe to mysql so that I can populate a database.

I tried using the following statement but it still breaks:

import signal

signal.signal(signal.SIGPIPE, signal.SIG_DFL)

Thanks,

Ruben
Jens.Toerring@physik.fu-berlin.de

2004-09-16, 11:16 am

Ruben <fernandezvictor77@hotmail.com> wrote:
> I am reading a large text file a chunk at a time using the
> readlines(buffer_size) statement. I get an IOERROR ERRNO 32 Broken
> Pipe command when I "pipe" the output to mysql database using the
> following command:


> Python script.py | mysql


> I am using RED HAT 9 Linux. The problem only happens if I use the pipe
> to MYSQL. It breaks but it gets to process around 1000 MYSQL
> statements.


The SIGPIPE signal is received by the writing process if there's
suddenly no reader anymore. So it looks as if your 'mysql' process
dies prematurely for some reason. Perhaps you should out the 'tee'
command in between to be able to see what really gets send to 'mysql'.

> If I only use the following statement:


> Python script.py


> The programs runs ok and reads all text records without problems. I
> do need to sent the pipe to mysql so that I can populate a database.


> I tried using the following statement but it still breaks:


> import signal
> signal.signal(signal.SIGPIPE, signal.SIG_DFL)


The default action for SIGPIPE is to kill the process that receives
it. But even if you would manage to keep the process alive by
giving the signal some other disposition that still wouldn't help
when the other side you want to send commands to does not live
anymore...
Regards, Jens
--
\ Jens Thoms Toerring ___ Jens.Toerring@physik.fu-berlin.de
\__________________________ http://www.toerring.de
Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com