popen2 bug?

Roman Suzi rnd at onego.ru
Tue Sep 18 07:43:03 EDT 2001


I came across unidentified difficulty when doing the following:

>>> d = (("a"*120) + "\n") * 300     # prepare data
>>> import popen2
>>> a, b = popen2.popen2("grep a")   # pipe to/from grep setup
>>> b.write(d)                       # trying to write... takes forever!
Traceback (innermost last):
  File "/usr/lib/python1.5/exceptions.py", line 102, in __init__
    def __init__(self, *args):
KeyboardInterrupt

- I used C-C to break.

I think this behavior is wrong! But I am not sure how to avoid it. It
happens when lines, passed to grep, are incomplete and when the incomplete
line matches.

My idea was to pipe logs thru grep and then read separate records as
lines.

Any ideas?

Maybe, there is fast grep/egrep for Python (Python version is 1.5.1)?
(One-by-line it too slow).

Sincerely yours, Roman A.Suzi
-- 
 - Petrozavodsk - Karelia - Russia - mailto:rnd at onego.ru -
 





More information about the Python-list mailing list