Does anyone know what I should do? I receive this error everytime I interact with my localhost.
It does not crash, my terminal just blows up with these exceptions. Does anyone know how I should proceed with this issue?
I know this is alot of errors but I am starting to learn more about Django so your help would be greatly appreciated. Thank you!
----------------------------------------
Exception happened during processing of request from ('127.0.0.1', 50979)
----------------------------------------
Exception happened during processing of request from ('127.0.0.1', 50974)
----------------------------------------
Exception happened during processing of request from ('127.0.0.1', 50978)
----------------------------------------
Exception happened during processing of request from ('127.0.0.1', 50980)
----------------------------------------
Exception happened during processing of request from ('127.0.0.1', 50981)
Traceback (most recent call last):
Traceback (most recent call last):
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/socketserver.py", line 650, in process_request_thread
self.finish_request(request, client_address)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/socketserver.py", line 360, in finish_request
self.RequestHandlerClass(request, client_address, self)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/socketserver.py", line 720, in __init__
self.handle()
File "/Users/Emmanuel/.local/share/virtualenvs/thepillow-kX0pGe6_/lib/python3.8/site-packages/django/core/servers/basehttp.py", line 174, in handle
self.handle_one_request()
File "/Users/Emmanuel/.local/share/virtualenvs/thepillow-kX0pGe6_/lib/python3.8/site-packages/django/core/servers/basehttp.py", line 182, in handle_one_request
self.raw_requestline = self.rfile.readline(65537)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/socket.py", line 669, in readinto
return self._sock.recv_into(b)
ConnectionResetError: [Errno 54] Connection reset by peer
----------------------------------------
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/socketserver.py", line 650, in process_request_thread
self.finish_request(request, client_address)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/socketserver.py", line 650, in process_request_thread
self.finish_request(request, client_address)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/socketserver.py", line 360, in finish_request
self.RequestHandlerClass(request, client_address, self)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/socketserver.py", line 720, in __init__
self.handle()
File "/Users/Emmanuel/.local/share/virtualenvs/thepillow-kX0pGe6_/lib/python3.8/site-packages/django/core/servers/basehttp.py", line 174, in handle
self.handle_one_request()
File "/Users/Emmanuel/.local/share/virtualenvs/thepillow-kX0pGe6_/lib/python3.8/site-packages/django/core/servers/basehttp.py", line 182, in handle_one_request
self.raw_requestline = self.rfile.readline(65537)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/socket.py", line 669, in readinto
return self._sock.recv_into(b)
ConnectionResetError: [Errno 54] Connection reset by peer
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/socketserver.py", line 650, in process_request_thread
self.finish_request(request, client_address)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/socketserver.py", line 360, in finish_request
self.RequestHandlerClass(request, client_address, self)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/socketserver.py", line 720, in __init__
self.handle()
File "/Users/Emmanuel/.local/share/virtualenvs/thepillow-kX0pGe6_/lib/python3.8/site-packages/django/core/servers/basehttp.py", line 174, in handle
self.handle_one_request()
File "/Users/Emmanuel/.local/share/virtualenvs/thepillow-kX0pGe6_/lib/python3.8/site-packages/django/core/servers/basehttp.py", line 182, in handle_one_request
self.raw_requestline = self.rfile.readline(65537)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/socket.py", line 669, in readinto
return self._sock.recv_into(b)
ConnectionResetError: [Errno 54] Connection reset by peer
----------------------------------------
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/socketserver.py", line 360, in finish_request
self.RequestHandlerClass(request, client_address, self)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/socketserver.py", line 720, in __init__
self.handle()
File "/Users/Emmanuel/.local/share/virtualenvs/thepillow-kX0pGe6_/lib/python3.8/site-packages/django/core/servers/basehttp.py", line 174, in handle
self.handle_one_request()
File "/Users/Emmanuel/.local/share/virtualenvs/thepillow-kX0pGe6_/lib/python3.8/site-packages/django/core/servers/basehttp.py", line 182, in handle_one_request
self.raw_requestline = self.rfile.readline(65537)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/socket.py", line 669, in readinto
return self._sock.recv_into(b)
ConnectionResetError: [Errno 54] Connection reset by peer
----------------------------------------
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/socketserver.py", line 650, in process_request_thread
self.finish_request(request, client_address)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/socketserver.py", line 360, in finish_request
self.RequestHandlerClass(request, client_address, self)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/socketserver.py", line 720, in __init__
self.handle()
File "/Users/Emmanuel/.local/share/virtualenvs/thepillow-kX0pGe6_/lib/python3.8/site-packages/django/core/servers/basehttp.py", line 174, in handle
self.handle_one_request()
File "/Users/Emmanuel/.local/share/virtualenvs/thepillow-kX0pGe6_/lib/python3.8/site-packages/django/core/servers/basehttp.py", line 182, in handle_one_request
self.raw_requestline = self.rfile.readline(65537)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/socket.py", line 669, in readinto
return self._sock.recv_into(b)
ConnectionResetError: [Errno 54] Connection reset by peer
----------------------------------------
----------------------------------------
Not Found: /favicon.ico
----------------------------------------
Exception happened during processing of request from ('127.0.0.1', 50982)
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/socketserver.py", line 650, in process_request_thread
self.finish_request(request, client_address)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/socketserver.py", line 360, in finish_request
self.RequestHandlerClass(request, client_address, self)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/socketserver.py", line 720, in __init__
self.handle()
File "/Users/Emmanuel/.local/share/virtualenvs/thepillow-kX0pGe6_/lib/python3.8/site-packages/django/core/servers/basehttp.py", line 174, in handle
self.handle_one_request()
File "/Users/Emmanuel/.local/share/virtualenvs/thepillow-kX0pGe6_/lib/python3.8/site-packages/django/core/servers/basehttp.py", line 182, in handle_one_request
self.raw_requestline = self.rfile.readline(65537)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/socket.py", line 669, in readinto
return self._sock.recv_into(b)
ConnectionResetError: [Errno 54] Connection reset by peer
'''
The issue is raised by the fav.ico because django server is always resetting after not finding a favicon so If you add one. Even though If you never explicitly load one, django try and load a default one from the root of the project. you can use favicon io to make a simple fav icon. you put it inside your static folder and load it like that :
{% load static %}
<head>
<link rel="shortcut icon" href="{% static 'images/favicon.ico' %}" />
Related
When running Flask scripts in localhost, I tried to access the webpages from another device in the same local network.
Although I'm able to view the webpages, I frequently noticed this error popping all of a sudden with random numbers near my IP in my console causing OSError and denying access for my later requests to the Flask server.
Exception happened during processing of request from ('192.168.0.4', 41252)
Exception happened during processing of request from ('192.168.0.4', 41250)
Traceback (most recent call last):
Traceback (most recent call last):
File "C:\Program Files\Python38\lib\socketserver.py", line 650, in process_request_thread
self.finish_request(request, client_address)
File "C:\Program Files\Python38\lib\socketserver.py", line 650, in process_request_thread
self.finish_request(request, client_address)
File "C:\Program Files\Python38\lib\socketserver.py", line 360, in finish_request
self.RequestHandlerClass(request, client_address, self)
File "C:\Program Files\Python38\lib\socketserver.py", line 720, in __init__
self.handle()
File "C:\Program Files\Python38\lib\socketserver.py", line 360, in finish_request
self.RequestHandlerClass(request, client_address, self)
File "C:\Users\me\AppData\Roaming\Python\Python38\site-packages\werkzeug\serving.py", line 329, in handle
rv = BaseHTTPRequestHandler.handle(self)
File "C:\Program Files\Python38\lib\socketserver.py", line 720, in __init__
self.handle()
File "C:\Program Files\Python38\lib\http\server.py", line 426, in handle
self.handle_one_request()
File "C:\Users\me\AppData\Roaming\Python\Python38\site-packages\werkzeug\serving.py", line 329, in handle
rv = BaseHTTPRequestHandler.handle(self)
File "C:\Program Files\Python38\lib\http\server.py", line 426, in handle
self.handle_one_request()
File "C:\Users\me\AppData\Roaming\Python\Python38\site-packages\werkzeug\serving.py", line 360, in handle_one_request
self.raw_requestline = self.rfile.readline()
File "C:\Program Files\Python38\lib\socket.py", line 669, in readinto
return self._sock.recv_into(b)
File "C:\Users\me\AppData\Roaming\Python\Python38\site-packages\werkzeug\serving.py", line 360, in handle_one_request
self.raw_requestline = self.rfile.readline()
File "C:\Program Files\Python38\lib\socket.py", line 669, in readinto
return self._sock.recv_into(b)
OSError: [WinError 10022] An invalid argument was supplied
OSError: [WinError 10022] An invalid argument was supplied
----------------------------------------
----------------------------------------
Exception happened during processing of request from ('192.168.0.4', 41378)
Exception happened during processing of request from ('192.168.0.4', 41380)
Traceback (most recent call last):
Traceback (most recent call last):
File "C:\Program Files\Python38\lib\socketserver.py", line 650, in process_request_thread
self.finish_request(request, client_address)
File "C:\Program Files\Python38\lib\socketserver.py", line 650, in process_request_thread
self.finish_request(request, client_address)
File "C:\Program Files\Python38\lib\socketserver.py", line 360, in finish_request
self.RequestHandlerClass(request, client_address, self)
File "C:\Program Files\Python38\lib\socketserver.py", line 360, in finish_request
self.RequestHandlerClass(request, client_address, self)
File "C:\Program Files\Python38\lib\socketserver.py", line 720, in __init__
self.handle()
File "C:\Program Files\Python38\lib\socketserver.py", line 720, in __init__
self.handle()
File "C:\Users\me\AppData\Roaming\Python\Python38\site-packages\werkzeug\serving.py", line 329, in handle
rv = BaseHTTPRequestHandler.handle(self)
File "C:\Users\me\AppData\Roaming\Python\Python38\site-packages\werkzeug\serving.py", line 329, in handle
rv = BaseHTTPRequestHandler.handle(self)
File "C:\Program Files\Python38\lib\http\server.py", line 426, in handle
self.handle_one_request()
File "C:\Users\me\AppData\Roaming\Python\Python38\site-packages\werkzeug\serving.py", line 360, in handle_one_request
self.raw_requestline = self.rfile.readline()
File "C:\Program Files\Python38\lib\http\server.py", line 426, in handle
self.handle_one_request()
File "C:\Users\me\AppData\Roaming\Python\Python38\site-packages\werkzeug\serving.py", line 360, in handle_one_request
self.raw_requestline = self.rfile.readline()
File "C:\Program Files\Python38\lib\socket.py", line 669, in readinto
return self._sock.recv_into(b)
File "C:\Program Files\Python38\lib\socket.py", line 669, in readinto
return self._sock.recv_into(b)
OSError: [WinError 10022] An invalid argument was supplied
OSError: [WinError 10022] An invalid argument was supplied
----------------------------------------
----------------------------------------
For all I know, I know nothing about sockets or other things thats in my error.
How do i stop such errors from happenning after all I'm just rendering a HTML template as a response?
Edit :
I'm adding a part of my Flask script here from which I still get the error. And again the error is something that occurs when I try to access my webpages from other devices connected in the network
from flask import *
app = Flask(__name__)
#app.route('/')
def index():
return render_template("home.html")
#app.route('/download')
def downloads():
return render_template("downloads.html")
if __name__ == '__main__':
app.run(host="0.0.0.0", port=5000 , debug = True)
This time also I got similar error as follows
----------------------------------------
Exception happened during processing of request from ('192.168.0.5', 42834)
Traceback (most recent call last):
File "C:\Program Files\Python38\lib\socketserver.py", line 650, in process_request_thread
self.finish_request(request, client_address)
File "C:\Program Files\Python38\lib\socketserver.py", line 360, in finish_request
self.RequestHandlerClass(request, client_address, self)
File "C:\Program Files\Python38\lib\socketserver.py", line 720, in __init__
self.handle()
File "C:\Users\me\AppData\Roaming\Python\Python38\site-packages\werkzeug\serving.py", line 329, in handle
rv = BaseHTTPRequestHandler.handle(self)
File "C:\Program Files\Python38\lib\http\server.py", line 426, in handle
self.handle_one_request()
File "C:\Users\me\AppData\Roaming\Python\Python38\site-packages\werkzeug\serving.py", line 360, in handle_one_request
self.raw_requestline = self.rfile.readline()
File "C:\Program Files\Python38\lib\socket.py", line 669, in readinto
return self._sock.recv_into(b)
OSError: [WinError 10022] An invalid argument was supplied
----------------------------------------
I am googling a lot to find the solution. Maybe this is windows or python bug. I am here for getting help. It is creating problem while debuging.
Traceback (most recent call last):
File "C:\Users\azad\AppData\Local\Programs\Python\Python36\lib\wsgiref\handlers.py", line 138, in run
self.finish_response()
File "C:\Users\azad\AppData\Local\Programs\Python\Python36\lib\wsgiref\handlers.py", line 180, in finish_response
self.write(data)
File "C:\Users\azad\AppData\Local\Programs\Python\Python36\lib\wsgiref\handlers.py", line 274, in write
self.send_headers()
File "C:\Users\azad\AppData\Local\Programs\Python\Python36\lib\wsgiref\handlers.py", line 332, in send_headers
self.send_preamble()
File "C:\Users\azad\AppData\Local\Programs\Python\Python36\lib\wsgiref\handlers.py", line 258, in send_preamble
self._write(('Server: %s\r\n' % self.server_software).encode('iso-8859-1'))
File "C:\Users\azad\AppData\Local\Programs\Python\Python36\lib\wsgiref\handlers.py", line 453, in _write
result = self.stdout.write(data)
File "C:\Users\azad\AppData\Local\Programs\Python\Python36\lib\socketserver.py", line 803, in write
self._sock.sendall(b)
ConnectionResetError: [WinError 10054] An existing connection was forcibly closed by the remote host
[19/Apr/2019 14:31:19] ERROR [django.server:154] "GET /static/node_modules/metronic-theme-classic/assets/media/logos/favicon.ico HTTP/1.1" 500 59
----------------------------------------
Exception happened during processing of request from ('127.0.0.1', 52183)
Traceback (most recent call last):
File "C:\Users\azad\AppData\Local\Programs\Python\Python36\lib\wsgiref\handlers.py", line 138, in run
self.finish_response()
File "C:\Users\azad\AppData\Local\Programs\Python\Python36\lib\wsgiref\handlers.py", line 180, in finish_response
self.write(data)
File "C:\Users\azad\AppData\Local\Programs\Python\Python36\lib\wsgiref\handlers.py", line 274, in write
self.send_headers()
File "C:\Users\azad\AppData\Local\Programs\Python\Python36\lib\wsgiref\handlers.py", line 332, in send_headers
self.send_preamble()
File "C:\Users\azad\AppData\Local\Programs\Python\Python36\lib\wsgiref\handlers.py", line 258, in send_preamble
self._write(('Server: %s\r\n' % self.server_software).encode('iso-8859-1'))
File "C:\Users\azad\AppData\Local\Programs\Python\Python36\lib\wsgiref\handlers.py", line 453, in _write
result = self.stdout.write(data)
File "C:\Users\azad\AppData\Local\Programs\Python\Python36\lib\socketserver.py", line 803, in write
self._sock.sendall(b)
ConnectionResetError: [WinError 10054] An existing connection was forcibly closed by the remote host
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\azad\AppData\Local\Programs\Python\Python36\lib\wsgiref\handlers.py", line 141, in run
self.handle_error()
File "C:\Users\azad\AppData\Local\Programs\Python\Python36\lib\site-packages\django\core\servers\basehttp.py", line 116, in handle_error
super().handle_error()
File "C:\Users\azad\AppData\Local\Programs\Python\Python36\lib\wsgiref\handlers.py", line 368, in handle_error
self.finish_response()
File "C:\Users\azad\AppData\Local\Programs\Python\Python36\lib\wsgiref\handlers.py", line 180, in finish_response
self.write(data)
File "C:\Users\azad\AppData\Local\Programs\Python\Python36\lib\wsgiref\handlers.py", line 274, in write
self.send_headers()
File "C:\Users\azad\AppData\Local\Programs\Python\Python36\lib\wsgiref\handlers.py", line 331, in send_headers
if not self.origin_server or self.client_is_modern():
File "C:\Users\azad\AppData\Local\Programs\Python\Python36\lib\wsgiref\handlers.py", line 344, in client_is_modern
return self.environ['SERVER_PROTOCOL'].upper() != 'HTTP/0.9'
TypeError: 'NoneType' object is not subscriptable
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\azad\AppData\Local\Programs\Python\Python36\lib\socketserver.py", line 654, in process_request_thread
self.finish_request(request, client_address)
File "C:\Users\azad\AppData\Local\Programs\Python\Python36\lib\socketserver.py", line 364, in finish_request
self.RequestHandlerClass(request, client_address, self)
File "C:\Users\azad\AppData\Local\Programs\Python\Python36\lib\socketserver.py", line 724, in __init__
self.handle()
File "C:\Users\azad\AppData\Local\Programs\Python\Python36\lib\site-packages\django\core\servers\basehttp.py", line 171, in handle
self.handle_one_request()
File "C:\Users\azad\AppData\Local\Programs\Python\Python36\lib\site-packages\django\core\servers\basehttp.py", line 194, in handle_one_request
handler.run(self.server.get_app())
File "C:\Users\azad\AppData\Local\Programs\Python\Python36\lib\wsgiref\handlers.py", line 144, in run
self.close()
File "C:\Users\azad\AppData\Local\Programs\Python\Python36\lib\site-packages\django\core\servers\basehttp.py", line 111, in close
super().close()
File "C:\Users\azad\AppData\Local\Programs\Python\Python36\lib\wsgiref\simple_server.py", line 35, in close
self.status.split(' ',1)[0], self.bytes_sent
AttributeError: 'NoneType' object has no attribute 'split'
----------------------------------------
Traceback (most recent call last):
File "C:\Users\azad\AppData\Local\Programs\Python\Python36\lib\wsgiref\handlers.py", line 138, in run
self.finish_response()
File "C:\Users\azad\AppData\Local\Programs\Python\Python36\lib\wsgiref\handlers.py", line 180, in finish_response
self.write(data)
File "C:\Users\azad\AppData\Local\Programs\Python\Python36\lib\wsgiref\handlers.py", line 274, in write
self.send_headers()
File "C:\Users\azad\AppData\Local\Programs\Python\Python36\lib\wsgiref\handlers.py", line 333, in send_headers
self._write(bytes(self.headers))
File "C:\Users\azad\AppData\Local\Programs\Python\Python36\lib\wsgiref\handlers.py", line 453, in _write
result = self.stdout.write(data)
File "C:\Users\azad\AppData\Local\Programs\Python\Python36\lib\socketserver.py", line 803, in write
self._sock.sendall(b)
ConnectionResetError: [WinError 10054] An existing connection was forcibly closed by the remote host
[19/Apr/2019 14:31:21] ERROR [django.server:154] "GET /static/node_modules/metronic-theme-classic/assets/media/logos/favicon.ico HTTP/1.1" 500 59
----------------------------------------
Exception happened during processing of request from ('127.0.0.1', 52185)
Traceback (most recent call last):
File "C:\Users\azad\AppData\Local\Programs\Python\Python36\lib\wsgiref\handlers.py", line 138, in run
self.finish_response()
File "C:\Users\azad\AppData\Local\Programs\Python\Python36\lib\wsgiref\handlers.py", line 180, in finish_response
self.write(data)
File "C:\Users\azad\AppData\Local\Programs\Python\Python36\lib\wsgiref\handlers.py", line 274, in write
self.send_headers()
File "C:\Users\azad\AppData\Local\Programs\Python\Python36\lib\wsgiref\handlers.py", line 333, in send_headers
self._write(bytes(self.headers))
File "C:\Users\azad\AppData\Local\Programs\Python\Python36\lib\wsgiref\handlers.py", line 453, in _write
result = self.stdout.write(data)
File "C:\Users\azad\AppData\Local\Programs\Python\Python36\lib\socketserver.py", line 803, in write
self._sock.sendall(b)
ConnectionResetError: [WinError 10054] An existing connection was forcibly closed by the remote host
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\azad\AppData\Local\Programs\Python\Python36\lib\wsgiref\handlers.py", line 141, in run
self.handle_error()
File "C:\Users\azad\AppData\Local\Programs\Python\Python36\lib\site-packages\django\core\servers\basehttp.py", line 116, in handle_error
super().handle_error()
File "C:\Users\azad\AppData\Local\Programs\Python\Python36\lib\wsgiref\handlers.py", line 368, in handle_error
self.finish_response()
File "C:\Users\azad\AppData\Local\Programs\Python\Python36\lib\wsgiref\handlers.py", line 180, in finish_response
self.write(data)
File "C:\Users\azad\AppData\Local\Programs\Python\Python36\lib\wsgiref\handlers.py", line 274, in write
self.send_headers()
File "C:\Users\azad\AppData\Local\Programs\Python\Python36\lib\wsgiref\handlers.py", line 331, in send_headers
if not self.origin_server or self.client_is_modern():
File "C:\Users\azad\AppData\Local\Programs\Python\Python36\lib\wsgiref\handlers.py", line 344, in client_is_modern
return self.environ['SERVER_PROTOCOL'].upper() != 'HTTP/0.9'
TypeError: 'NoneType' object is not subscriptable
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\azad\AppData\Local\Programs\Python\Python36\lib\socketserver.py", line 654, in process_request_thread
self.finish_request(request, client_address)
File "C:\Users\azad\AppData\Local\Programs\Python\Python36\lib\socketserver.py", line 364, in finish_request
self.RequestHandlerClass(request, client_address, self)
File "C:\Users\azad\AppData\Local\Programs\Python\Python36\lib\socketserver.py", line 724, in __init__
self.handle()
File "C:\Users\azad\AppData\Local\Programs\Python\Python36\lib\site-packages\django\core\servers\basehttp.py", line 171, in handle
self.handle_one_request()
File "C:\Users\azad\AppData\Local\Programs\Python\Python36\lib\site-packages\django\core\servers\basehttp.py", line 194, in handle_one_request
handler.run(self.server.get_app())
File "C:\Users\azad\AppData\Local\Programs\Python\Python36\lib\wsgiref\handlers.py", line 144, in run
self.close()
File "C:\Users\azad\AppData\Local\Programs\Python\Python36\lib\site-packages\django\core\servers\basehttp.py", line 111, in close
super().close()
File "C:\Users\azad\AppData\Local\Programs\Python\Python36\lib\wsgiref\simple_server.py", line 35, in close
self.status.split(' ',1)[0], self.bytes_sent
AttributeError: 'NoneType' object has no attribute 'split'
when i run my code the printer.py returns the below error
Error: printer.py
Traceback (most recent call last):
File "/usr/lib/python2.7/SocketServer.py", line 596, in process_request_thread
self.finish_request(request, client_address)
File "/usr/lib/python2.7/SocketServer.py", line 331, in finish_request
self.RequestHandlerClass(request, client_address, self)
File "/usr/lib/python2.7/SocketServer.py", line 652, in __init__
self.handle()
File "/usr/lib/python2.7/BaseHTTPServer.py", line 340, in handle
self.handle_one_request()
File "/usr/lib/python2.7/BaseHTTPServer.py", line 328, in handle_one_request
method()
File "server.py", line 67, in do_GET
print_dev = Usb(connected[0]['vendor'], connected[0]['product'])
File "/home/acespritech/projects/Printing Code/escpos/printer.py", line 32, in __init__
self.open()
File "/home/acespritech/projects/Printing Code/escpos/printer.py", line 60, in open
self.out_ep = endpoint_out.bEndpointAddress
AttributeError: 'NoneType' object has no attribute 'bEndpointAddress'
I'm sending a file with the following route
#app.route('/file/')
#db_session
def file():
filename = request.args.get('filename')
response = make_response(filename)
response.headers['Content-Type'] = 'video/mp3'
response.headers["Content-Disposition"] = 'attachment; filename=%s' % filename
response.headers['Content-Length'] = os.path.getsize(filename)
response.headers["X-Accel-Redirect"] = '%s' % filename
return send_file(
filename,
mimetype="audio/mp3",
as_attachment=True,
attachment_filename="%s" % filename)
It works fine in most desktop browsers and some mobile browsers. But on others it does not, and I get this error
68.9.161.152 - - [13/Dec/2015 05:27:24] "GET /mp4/?filename=video/How_To_Shave_Your_Beard_Like_A_Man.mp4 HTTP/1.1" 200 -
Exception in thread Thread-1:
Traceback (most recent call last):
File "/usr/lib/python2.7/threading.py", line 810, in __bootstrap_inner
self.run()
File "/usr/lib/python2.7/threading.py", line 763, in run
self.__target(*self.__args, **self.__kwargs)
File "/home/www/env/local/lib/python2.7/site-packages/werkzeug/serving.py", line 653, in inner
fd=fd).serve_forever()
File "/home/www/env/local/lib/python2.7/site-packages/werkzeug/serving.py", line 505, in serve_forever
HTTPServer.serve_forever(self)
File "/usr/lib/python2.7/SocketServer.py", line 238, in serve_forever
self._handle_request_noblock()
File "/usr/lib/python2.7/SocketServer.py", line 297, in _handle_request_noblock
self.handle_error(request, client_address)
File "/usr/lib/python2.7/SocketServer.py", line 295, in _handle_request_noblock
self.process_request(request, client_address)
File "/usr/lib/python2.7/SocketServer.py", line 321, in process_request
self.finish_request(request, client_address)
File "/usr/lib/python2.7/SocketServer.py", line 334, in finish_request
self.RequestHandlerClass(request, client_address, self)
File "/usr/lib/python2.7/SocketServer.py", line 649, in __init__
self.handle()
File "/home/www/env/local/lib/python2.7/site-packages/werkzeug/serving.py", line 217, in handle
rv = BaseHTTPRequestHandler.handle(self)
File "/usr/lib/python2.7/BaseHTTPServer.py", line 340, in handle
self.handle_one_request()
File "/home/www/env/local/lib/python2.7/site-packages/werkzeug/serving.py", line 252, in handle_one_request
return self.run_wsgi()
File "/home/www/env/local/lib/python2.7/site-packages/werkzeug/serving.py", line 194, in run_wsgi
execute(self.server.app)
File "/home/www/env/local/lib/python2.7/site-packages/werkzeug/serving.py", line 185, in execute
write(data)
File "/home/www/env/local/lib/python2.7/site-packages/werkzeug/serving.py", line 166, in write
self.wfile.write(data)
I've tried putting time.sleep(1) randomly in order to try and help.
I am having some problem with using python's Bottle framework(http://bottlepy.org/docs/dev/index.html) to host a webpage. It seems to work fine for certain period of time but now and then I get the following error and it fails to show the webpage. The script doesn't crash but the webpage becomes non responsive.
Any suggestions?
Traceback (most recent call last):
File "/usr/lib/python2.7/SocketServer.py", line 295, in _handle_request_noblock
self.process_request(request, client_address)
File "/usr/lib/python2.7/SocketServer.py", line 321, in process_request
self.finish_request(request, client_address)
File "/usr/lib/python2.7/SocketServer.py", line 334, in finish_request
self.RequestHandlerClass(request, client_address, self)
File "/usr/lib/python2.7/SocketServer.py", line 651, in __init__
self.finish()
File "/usr/lib/python2.7/SocketServer.py", line 710, in finish
self.wfile.close()
File "/usr/lib/python2.7/socket.py", line 279, in close
self.flush()
File "/usr/lib/python2.7/socket.py", line 303, in flush
self._sock.sendall(view[write_offset:write_offset+buffer_size])
error: [Errno 32] Broken pipe
I also see the following error. But I'm guessing these occur if a request to a non-existent webpage/object is requested-
Traceback (most recent call last):
File "/usr/lib/python2.7/SocketServer.py", line 295, in _handle_request_noblock
self.process_request(request, client_address)
File "/usr/lib/python2.7/SocketServer.py", line 321, in process_request
self.finish_request(request, client_address)
File "/usr/lib/python2.7/SocketServer.py", line 334, in finish_request
self.RequestHandlerClass(request, client_address, self)
File "/usr/lib/python2.7/SocketServer.py", line 649, in __init__
self.handle()
File "/usr/lib/python2.7/wsgiref/simple_server.py", line 116, in handle
self.raw_requestline = self.rfile.readline()
File "/usr/lib/python2.7/socket.py", line 447, in readline
data = self._sock.recv(self._rbufsize)
error: [Errno 104] Connection reset by peer
This question seems to be similar to How to prevent errno 32 broken pipe?
You received a SIGPIPE and this could be due to attempting to write to a closed socket. You could try to handle the exception with something like that:
except socket.error, e:
if isinstance(e.args, tuple):
print "Errno: %d" % e[0]
if e[0] == errno.EPIPE:
# Caught a peer disconnection
print "Remote host disconnected"