New submission from François-Xavier Bourlet <[email protected]>:
Actually the class asyncore.dispatcher_with_send do not handle properly
disconnection. When the endpoint shutdown his sending part of the socket, but
keep the socket open in reading, the current implementation of
dispatcher_with_send will close the socket without sending pending data.
Adding this method to the class fix the problem:
def handle_close(self):
if not self.writable():
dispatcher.close()
Note also that this class try to initiate a send even if the socket is maybe
not ready for writing:
Here's a simple fix:
def send(self, data):
if self.debug:
self.log_info('sending %s' % repr(data))
self.out_buffer = self.out_buffer + data
- self.initiate_send()
Last but not last, the buffer size of each socket send are way to small (512, a
third of an usual TCP frame). Here's the code with a bumped value:
def initiate_send(self):
num_sent = 0
- num_sent = dispatcher.send(self, self.out_buffer[:512])
+ num_sent = dispatcher.send(self, self.out_buffer[:8192])
self.out_buffer = self.out_buffer[num_sent:]
Thanks for reading,
----------
components: IO
messages: 139821
nosy: François-Xavier.Bourlet
priority: normal
severity: normal
status: open
title: asyncore.dispatcher_with_send, disconnection problem + miss-conception
versions: Python 2.7
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue12498>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com