Can't reconnect with asyncore.
Alexander Semenov
sav at ulj.menatepspb.com
Tue Nov 26 15:43:20 EST 2002
Hi,
Here is my code (WinXP, python22):
import socket, asyncore, asynchat
class strange_client(asynchat.async_chat):
def __init__(self):
asynchat.async_chat.__init__(self)
self.create_socket(socket.AF_INET, socket.SOCK_STREAM)
self.connect(('192.168.32.30', 110))
self.push('USER sav\n')
self.set_terminator('\r\n')
self._buff = []
def collect_incoming_data(self, data):
self._buff.append(data)
def found_terminator(self):
print self._buff
self._buff = []
self.push('USER sav\n')
def handle_close(self):
self.close()
print 'Reconnecting...'
strange_client()
strange_client()
asyncore.loop()
I'm trying to reach persistent client connection with asyncore,
which can autorestore itself on errors. When I run this code I see
C:\wrk\wrk>clitest.py
warning: unhandled connect event
['+OK POP3 server ready ]
['+OK please send PASS command']
...
['+OK please send PASS command']
It's ok. Now I break connection (dialup in my case) to server.
...
['+OK please send PASS command']
Reconnecting...
...and program is stuck. I have no success in waking it at all.
Restoring dialup connection has no effect. Why so? How can
I done this with asyncore? My program will be used on linux,
maybe this problem disappered there?
Alexander Semenov.
More information about the Python-list
mailing list