Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using 'yield' in bottle gets an exception #6

Open
ClericPy opened this issue Nov 8, 2015 · 0 comments
Open

Using 'yield' in bottle gets an exception #6

ClericPy opened this issue Nov 8, 2015 · 0 comments

Comments

@ClericPy
Copy link

ClericPy commented Nov 8, 2015


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 .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant