wsgi-request-logger
wsgi-request-logger copied to clipboard
Using 'yield' in bottle gets an exception
Exception happened during processing of request from ('127.0.0.1', 50163) Traceback (most recent call last): File "D:\python35\lib\site-packages\paste\httpserver.py", line 1085, in process_request_in_thread self.finish_request(request, client_address) File "D:\python35\lib\socketserver.py", line 357, in finish_request self.RequestHandlerClass(request, client_address, self) File "D:\python35\lib\socketserver.py", line 684, in init self.handle() File "D:\python35\lib\site-packages\paste\httpserver.py", line 459, in handle BaseHTTPRequestHandler.handle(self) File "D:\python35\lib\http\server.py", line 415, in handle self.handle_one_request() File "D:\python35\lib\site-packages\paste\httpserver.py", line 454, in handle_one_request self.wsgi_execute() File "D:\python35\lib\site-packages\paste\httpserver.py", line 309, in wsgi_execute self.wsgi_write_chunk('') File "D:\python35\lib\site-packages\paste\httpserver.py", line 167, in wsgi_write_chunk self.wfile.write(chunk) File "D:\python35\lib\socket.py", line 589, in write return self._sock.send(b)
TypeError: a bytes-like object is required, not 'str'
Sorry to bother you again, this error occurs once on the old repository "bottlelog" too, my source code contains "yield" instead of "return".
Then I made a try,
from bottle import get, run, Bottle
app = Bottle()
@app.get('/index')
def aa():
return '''bla bla'''
@app.get('/index1')
def aa():
yield '''bla bla'''
return
# from requestlogger import WSGILogger, ApacheFormatter
# from logging.handlers import TimedRotatingFileHandler
# handlers = [ TimedRotatingFileHandler('access.log', 'd', 7) , ]
# app = WSGILogger(app, handlers, ApacheFormatter())
run(app, host='0.0.0.0', port=8081)
The same code, as long as I del the code contains requestlogger, 'index1' goes well, if retains them, 'index1' can not show anything .