By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,995 Members | 1,217 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,995 IT Pros & Developers. It's quick & easy.

the pipe reading in Thread dose not work.

P: n/a

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

import string, sys
from threading import Thread
import os
import time

class test_pipe(Thread):
def __init__(self, fd):
self.testfd = fd

def run(self):
print "started thread begin -----"
while True:
buf =
print "receive %s" % (buf)
#print "hoho"

if __name__ == "__main__":

stdin_r, stdin_w = os.pipe()
#stdout_r, stdout_w = pipe()

f_w = os.fdopen(stdin_w, "w", 0)

thrd = test_pipe(os.fdopen(stdin_r, "r", 0))


while True:

well, I want the following small test about pipe() in thread().
OK, I write to the pipe in the main thread, and I created a new thread
for reading from the pipe, then it will print what it received from
the pipe().

But, it seems it block at the "".

So, is there and suggestion and explaination about it?

Thanks in advance.
Jun 1 '08 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.