急!!python 出现:[Errno 11] Resource temporarily unavailable
急!!!我在python去接收recv()。出现
error: uncaptured python exception, closing channel <AirPlayService.AirPlayProtocolHandler connected 172.16.11.237:60833 at 0x9024d4c> (<class 'socket.error'>:[Errno 11] Resource temporarily unavailable [/usr/lib/python2.6/asyncore.py|read|78] [/usr/lib/python2.6/asyncore.py|handle_read_event|428] [/root/.local/share/totem/plugins/airplay/totem-plugin-airplay/AirPlayService.py|handle_read|101] [/root/.local/share/totem/plugins/airplay/totem-plugin-airplay/AirPlayService.py|read_from_socket|74] [/usr/lib/python2.6/asyncore.py|recv|373])
我的代码是:
def read_from_socket(self, socket):
data = socket.recv(1024)
print "yy test baseairplayrequest@@@@@@ %s" %(data)
if not data:
return False
print "yy test BaseAirPlayRequest@@@@@@@@@2"
# we split the message into HTTP headers and content body
message = data.split("\r\n\r\n", 1)
headers = message[0]
headerlines = headers.splitlines()
# parse request headers
command = headerlines[0].split()
self.type = command[0]
self.uri = command[1]
self.version = command[2]
del headerlines[0]
self.headers = self.parse_headers(headerlines)
# parse any uri query parameters
print "yy test BaseAirPlayRequest parse any uri query parameters"
self.params = None
if (self.uri.find('?')):
url = urlparse(self.uri)
if (url[4] is not ""):
self.params = dict([part.split('=') for part in url[4].split('&')])
self.uri = url[2]
# parse message body
if (int(self.headers['Content-Length']) > 0):
self.body = message[1]
print "len body=%d, len content = %d" %(len(self.body),int(self.headers['Content-Length']))
# read more data if we have to
if len(self.body) < int(self.headers['Content-Length']):
while 1:
print "while 11111111111"
data = socket.recv(8196)
print "!!!data = %s,len = %d" %(data,len(data))
if not data:
break
self.body = self.body + data
在while 1里面 循环了两次以后就出现问题。我客户端的数据是ok的,我抓包可以看到数据已经全部都可以下来。所以可以排除客户端问题,网上说设置非阻塞socket.setblocking(0)就可以,但是我设置了也没用。急,谁能帮看看