python flask web开发
本地码代码,push到coding,阿里服务器pull下来,在服务器环境下运行python app.py
打开网页,经常卡主不动,在命令行摁两下CTRL+C
,才能继续运行,后台显示如下,求大神指点迷津,拜谢
^C^C----------####背景------------------------------
Exception happened during processing of request from ('61.149.176.46', 34151)
Traceback (most recent call last):
File "/usr/lib64/python2.7/SocketServer.py", line 295, in _handle_request_noblock
self.process_request(request, client_address)
File "/usr/lib64/python2.7/SocketServer.py", line 321, in process_request
self.finish_request(request, client_address)
File "/usr/lib64/python2.7/SocketServer.py", line 334, in finish_request
self.RequestHandlerClass(request, client_address, self)
File "/usr/lib64/python2.7/SocketServer.py", line 651, in __init__
self.finish()
File "/usr/lib64/python2.7/SocketServer.py", line 705, in finish
self.wfile.flush()
File "/usr/lib64/python2.7/socket.py", line 303, in flush
self._sock.sendall(view[write_offset:write_offset+buffer_size])
KeyboardInterrupt
----------------------------------------
1) Ctrl+C的作用只是给当前的进程发送一个信号量,在Linux下,这个默认的信号量是SIGINT.默认程序是不抓取的,并且收到这个信号就退出,除非你自己程序显示拦截,信号量你可以看下这里
https://www.baidu.com/s?ie=utf-8&f=8&rsv...
有关python拦截信号量随手写个小例子,见
2) 从你程序退出的堆栈来看,程序不是卡住,而是阻塞在self._sock.sendall,也就是阻塞在给对方的socket发数据的函数里,你检查下是否到你的'61.149.176.46', 34151存在很大的数据量的情况