Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > reading from pipe

Reply
Thread Tools

reading from pipe

 
 
Richard Lamboj
Guest
Posts: n/a
 
      01-25-2010

Hello,

is there any solution to catch if a pipe has closed? Maybe the signal modul?

For Simulation:
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys

while True:
line = sys.stdin.readline()

sys.stdout.write(line)
sys.stdout.flush()

time cat /tmp/proxy.test | test.py

Solution:
if line == "":
break

Kind Regards,

Richi
 
Reply With Quote
 
 
 
 
Lutz Horn
Guest
Posts: n/a
 
      01-25-2010
Hi,

Richard Lamboj schrieb:
> is there any solution to catch if a pipe has closed? Maybe the signal modul?


Since sys.stdin is a file object, you can use sys.stdin.closed to check
if it has been closed.

Lutz
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
reading from stdin via pipe, buffering? Rudy Gevaert Perl 2 03-15-2008 08:43 AM
fread() blocks when reading pipe with closed write end bill C Programming 4 11-09-2005 02:18 AM
[named pipe] i wanna know about validate of pipe handle of client lee, wonsun C++ 1 11-02-2004 04:29 AM
Why does IO::Pipe::END generate an EXCEPT pipe message? lvirden@gmail.com Perl Misc 1 06-02-2004 02:17 PM
reading from pipe Rolf Wester C Programming 2 10-17-2003 01:29 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57