AttributeError: 'NoneType' object has no attribute 'split' Problem

The following error message occurs in response Python3 network programming interface configured to stream media or other 'Content-Type' type:

Traceback (most recent call last):
  File "/usr/lib/python3.6/wsgiref/handlers.py", line 138, in run
    self.finish_response()
  File "/usr/lib/python3.6/wsgiref/handlers.py", line 180, in finish_response
    self.write(data)
  File "/usr/lib/python3.6/wsgiref/handlers.py", line 279, in write
    self._write(data)
  File "/usr/lib/python3.6/wsgiref/handlers.py", line 453, in _write
    result = self.stdout.write(data)
  File "/usr/lib/python3.6/socketserver.py", line 803, in write
    self._sock.sendall(b)
ConnectionResetError: [Errno 104] Connection reset by peer
ERROR basehttp 124 "GET /control/v1/video_address?file_path=/fsdata/videos/1.mp4/h264_1.MP4 HTTP/1.1" 500 59
----------------------------------------
Exception happened during processing of request from ('192.168.2.63', 58153)
Traceback (most recent call last):
  File "/usr/lib/python3.6/wsgiref/handlers.py", line 138, in run
    self.finish_response()
  File "/usr/lib/python3.6/wsgiref/handlers.py", line 180, in finish_response
    self.write(data)
  File "/usr/lib/python3.6/wsgiref/handlers.py", line 279, in write
    self._write(data)
  File "/usr/lib/python3.6/wsgiref/handlers.py", line 453, in _write
    result = self.stdout.write(data)
  File "/usr/lib/python3.6/socketserver.py", line 803, in write
    self._sock.sendall(b)
ConnectionResetError: [Errno 104] Connection reset by peer

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.6/wsgiref/handlers.py", line 141, in run
    self.handle_error()
  File "/usr/local/lib/python3.6/dist-packages/django/core/servers/basehttp.py", line 88, in handle_error
    super(ServerHandler, self).handle_error()
  File "/usr/lib/python3.6/wsgiref/handlers.py", line 368, in handle_error
    self.finish_response()
  File "/usr/lib/python3.6/wsgiref/handlers.py", line 180, in finish_response
    self.write(data)
  File "/usr/lib/python3.6/wsgiref/handlers.py", line 274, in write
    self.send_headers()
  File "/usr/lib/python3.6/wsgiref/handlers.py", line 331, in send_headers
    if not self.origin_server or self.client_is_modern():
  File "/usr/lib/python3.6/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 "/usr/lib/python3.6/socketserver.py", line 654, in process_request_thread
    self.finish_request(request, client_address)
  File "/usr/lib/python3.6/socketserver.py", line 364, in finish_request
    self.RequestHandlerClass(request, client_address, self)
  File "/usr/lib/python3.6/socketserver.py", line 724, in __init__
    self.handle()
  File "/usr/local/lib/python3.6/dist-packages/django/core/servers/basehttp.py", line 155, in handle
    handler.run(self.server.get_app())
  File "/usr/lib/python3.6/wsgiref/handlers.py", line 144, in run
    self.close()
  File "/usr/lib/python3.6/wsgiref/simple_server.py", line 35, in close
    self.status.split(' ',1)[0], self.bytes_sent
AttributeError: 'NoneType' object has no attribute 'split'
----------------------------------------

After testing this exception does not affect the program's operation and interface data return, but an exception is thrown so much to see I was feeling uncomfortable, but the project did not need to collect the log so many useless abnormality affecting other abnormal position, course, you can ignore this an exception is not collected, but only in patients with obsessive-compulsive disorder to consider how to solve this problem, find solutions online, mostly spam that have no nutrition, and finally their own follow-up program to view the underlying source code, solve process is as follows:
first, according to the first line prompt:

File "C:\Python34\lib\wsgiref\handlers.py", line 138, in run
self.finish_response()

I use the editor is pycharm, 138 line handlers.py find the file, hold down the finish_response ctrl click on the file () method,

To find self.finish_response (defined position) a. According to Article tips:

File "C:\Python34\lib\wsgiref\handlers.py", line 181, in finish_response
self.write(data)

Write error method is found, then hold down ctrl click on the write method, find the location of the definition of write method, we found a first line defines the error:

assert type(data) is bytes, \
"write() argument must be a bytes instance"

Control information given above, may be found to be of variable data type, not bytes, so the addition of a line of code in handlers.py181 self.write (data) above:

data=data.encode()

Will be prompted to modify, you can choose to modify

Here Insert Picture Description
Here Insert Picture Description
Refresh program again, I find all error is gone, the program running.

Published 20 original articles · won praise 40 · views 5800

Guess you like

Origin blog.csdn.net/file_data/article/details/99640009