[Checkins] SVN: Sandbox/J1m/resumelb/src/zc/resumelb/ Fixed bug in handling empty strings in application-returned iterators.
Jim Fulton
jim at zope.com
Wed Feb 1 11:03:46 UTC 2012
Log message for revision 124269:
Fixed bug in handling empty strings in application-returned iterators.
Changed:
U Sandbox/J1m/resumelb/src/zc/resumelb/tests.py
U Sandbox/J1m/resumelb/src/zc/resumelb/worker.py
U Sandbox/J1m/resumelb/src/zc/resumelb/worker.test
-=-
Modified: Sandbox/J1m/resumelb/src/zc/resumelb/tests.py
===================================================================
--- Sandbox/J1m/resumelb/src/zc/resumelb/tests.py 2012-01-31 12:50:12 UTC (rev 124268)
+++ Sandbox/J1m/resumelb/src/zc/resumelb/tests.py 2012-02-01 11:03:46 UTC (rev 124269)
@@ -43,6 +43,15 @@
app_iter=['hello world\n'*1000]*size,
content_length=12000*size)
+ at bobo.query('/sneaky.html')
+def sneaky():
+ # The app_iter has empty strings!
+ return webob.Response(
+ app_iter=['', 'hello world\n'],
+ content_length=12)
+
+
+
@bobo.query('/sleep.html')
def sleep(dur=0):
time.sleep(float(dur))
Modified: Sandbox/J1m/resumelb/src/zc/resumelb/worker.py
===================================================================
--- Sandbox/J1m/resumelb/src/zc/resumelb/worker.py 2012-01-31 12:50:12 UTC (rev 124268)
+++ Sandbox/J1m/resumelb/src/zc/resumelb/worker.py 2012-02-01 11:03:46 UTC (rev 124269)
@@ -105,7 +105,8 @@
body = self.apply(self.app, (env, start_response))
conn.put((rno, response[0]))
for data in body:
- conn.put((rno, data))
+ if data:
+ conn.put((rno, data))
conn.put((rno, ''))
Modified: Sandbox/J1m/resumelb/src/zc/resumelb/worker.test
===================================================================
--- Sandbox/J1m/resumelb/src/zc/resumelb/worker.test 2012-01-31 12:50:12 UTC (rev 124268)
+++ Sandbox/J1m/resumelb/src/zc/resumelb/worker.test 2012-02-01 11:03:46 UTC (rev 124269)
@@ -400,3 +400,21 @@
>>> with open('resume.mar') as f:
... list(marshal.load(f))
['test']
+
+Ignore empty strings in application iterables
+---------------------------------------------
+
+The lb/worker protocol uses empty strings as indicate end-of-message
+markers. If an application returns empty strings in it's returned
+iterable, the worker must ignore them.
+
+ >>> env = newenv('test', '/sneaky.html')
+ >>> write_message(worker_socket, 3, env, '')
+ >>> print_response(worker_socket, 3) # doctest: +ELLIPSIS
+ 3 200 OK
+ Content-Length: 12
+ Content-Type: text/html; charset=UTF-8
+ <BLANKLINE>
+ hello world
+
+ >>> worker.stop()
More information about the checkins
mailing list