Anonymous avatar Anonymous committed 7dc21f3

Added testcase showing broken behavior of GreenPipe object.
write larger PIPE_BUF size 4K or 64K on newer systems will be retried in full instead of continued.
I see no way to fix it while using file.write - it does not return written size.
os.write does.

Comments (0)

Files changed (1)

tests/greenio_test.py

 
         gt.wait()
 
+    def test_pipe_writes_large_messages(self):
+        r, w = os.pipe()
+
+        r = os.fdopen(r)
+        w = os.fdopen(w, 'w', 0)
+
+        r = greenio.GreenPipe(r)
+        w = greenio.GreenPipe(w)
+
+        large_message = "".join([1024*chr(i) for i in xrange(65)])
+        def writer():
+            w.write(large_message)
+            w.close()
+
+        gt = eventlet.spawn(writer)
+
+        for i in xrange(65):
+            buf = r.read(1024)
+            expected = 1024*chr(i) 
+            self.assertEquals(buf, expected, 
+                "expected=%r..%r, found=%r..%r iter=%d" 
+                % (expected[:4], expected[-4:], buf[:4], buf[-4:], i))
+        gt.wait()
+
+
     @skip_with_pyevent
     def test_raised_multiple_readers(self):
         debug.hub_prevent_multiple_readers(True)
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.