summaryrefslogtreecommitdiff
path: root/eventlet/support/__init__.py
diff options
context:
space:
mode:
Diffstat (limited to 'eventlet/support/__init__.py')
-rw-r--r--eventlet/support/__init__.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/eventlet/support/__init__.py b/eventlet/support/__init__.py
index 4c2b75d..de6b1e2 100644
--- a/eventlet/support/__init__.py
+++ b/eventlet/support/__init__.py
@@ -53,3 +53,16 @@ def capture_stderr():
finally:
sys.stderr = original
stream.seek(0)
+
+
+if six.PY2:
+ def safe_writelines(fd, to_write):
+ fd.writelines(to_write)
+else:
+ def safe_writelines(fd, to_write):
+ # Standard Python 3 writelines() is not reliable because it doesn't care if it
+ # loses data. See CPython bug report: http://bugs.python.org/issue26292
+ for item in to_write:
+ written = 0
+ while written < len(item):
+ written += fd.write(item[written:])