winerror 10053 python_ConnectionAbortedError: [WinError 10053] 你的主机中的软件中止了一个已建立的连接...

这篇博客记录了在Python中遇到WinError 10053错误的情况,该错误通常与网络连接中断有关。错误出现在wsgiref库的处理过程中。博主分享了一个可能的解决方案,即在使用AJAX时设置async为false,以确保同步执行,避免异步导致的问题。
摘要由CSDN通过智能技术生成

Traceback (most recent call last):

File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37\lib\wsgiref\handlers.py", line 138, in run

self.finish_response()

File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37\lib\wsgiref\handlers.py", line 180, in finish_response

self.write(data)

File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37\lib\wsgiref\handlers.py", line 274, in write

self.send_headers()

File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37\lib\wsgiref\handlers.py", line 332, in send_headers

self.send_preamble()

File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37\lib\wsgiref\handlers.py", line 255, in send_preamble

('Date: %s\r\n' % format_date_time(time.time())).encode('iso-8859-1')

File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37\lib\wsgiref\handlers.py", line 453, in _write

result = self.stdout.write(data)

File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37\lib\socketserver.py", line 796, in write

self._sock.sendall(b)

ConnectionAbortedError: [WinError 10053] 你的主机中的软件中止了一个已建立的连接。

[09/Apr/2019 18:30:05] "POST /userctrl/orders HTTP/1.1" 500 59

----------------------------------------

Exception happened during processing of request from ('127.0.0.1', 55521)

Traceback (most recent call last):

File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37\lib\wsgiref\handlers.py", line 138, in run

self.finish_response()

File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37\lib\wsgiref\handlers.py", line 180, in finish_response

self.write(data)

File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37\lib\wsgiref\handlers.py", line 274, in write

self.send_headers()

File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37\lib\wsgiref\handlers.py", line 332, in send_headers

self.send_preamble()

File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37\lib\wsgiref\handlers.py", line 255, in send_preamble

('Date: %s\r\n' % format_date_time(time.time())).encode('iso-8859-1')

File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37\lib\wsgiref\handlers.py", line 453, in _write

result = self.stdout.write(data)

File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37\lib\socketserver.py", line 796, in write

self._sock.sendall(b)

ConnectionAbortedError: [WinError 10053] 你的主机中的软件中止了一个已建立的连接。

During handling of the above exception, another exception occurred:

Traceback (most recent call last):

File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37\lib\wsgiref\handlers.py", line 141, in run

self.handle_error()

File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37\lib\site-packages\django\core\servers\basehttp.py", line 86, in handle_error

super().handle_error()

File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37\lib\wsgiref\handlers.py", line 368, in handle_error

self.finish_response()

File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37\lib\wsgiref\handlers.py", line 180, in finish_response

self.write(data)

File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37\lib\wsgiref\handlers.py", line 274, in write

self.send_headers()

File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37\lib\wsgiref\handlers.py", line 331, in send_headers

if not self.origin_server or self.client_is_modern():

File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37\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\Administrator\AppData\Local\Programs\Python\Python37\lib\socketserver.py", line 647, in process_request_thread

self.finish_request(request, client_address)

File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37\lib\socketserver.py", line 357, in finish_request

self.RequestHandlerClass(request, client_address, self)

File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37\lib\socketserver.py", line 717, in __init__

self.handle()

File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37\lib\site-packages\django\core\servers\basehttp.py", line 154, in handle

handler.run(self.server.get_app())

File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37\lib\wsgiref\handlers.py", line 144, in run

self.close()

File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37\lib\wsgiref\simple_server.py", line 35, in close

self.status.split(' ',1)[0], self.bytes_sent

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

----------------------------------------

在网上找到解决办法特随笔:

原因:ajax默认是异步提交,可是有时候我们会发现,本来要求请求马上出现,可是异步会导致后面突然再执行,这样就出问题了。

解决办法:

function jie(){

$.ajax({

url:"http://127.0.0.1:8000/userctrl/orders",

data:{'user':$.cookie("username"),"good_name":$(".good_name").text(),},

type:"post",

async:false,

dataType:"text",success:function(obj){

})

})

}

**标黄解决

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值