I am writing an Imap client. The Imap server (Groupwise) I connect to is really slow at accepting logins. So I have made a connection pool where I store the open connections to the server. But once in a while I get a memory segment error on the server and it crashes. I suspect what happens is that a connection has been idle for to long, ad the connection dropped by the imap server. Which might cause some memory to be freed that is then accessed when I call noop(). It could also be be some kind of threading problem. Does any of you hav an ide as to how I can find out? I am not used to these kind of problems, having been spoiled by Python for too long. regards Max M I have attached the connection pool code in the bottom. ########################################## # a borg/singleton for pooling connections. # Necessary as login can take a looong time class ConnectionPool: __shared_state = {} def __init__(self): self.__dict__ = self.__shared_state def getConnection(self, server_uri, user, password): if not hasattr(self, 'connections'): self.connections = {} user_key = (server_uri, user, password) user_connections = self.connections.setdefault(user_key, []) # first try and return a connection from the pool for i in range(len(user_connections)-1, -1, -1): # a connection can be timed out, # try noop to see if it's still open connection = user_connections[i] try: connection.noop() return user_connections.pop(i) except: # else login again user_connections.pop(i) # if no usable connections in the pool, # create new one and return it return Imap4Connector(server_uri, user, password) def release(self, connection): # take the connection and put it in the pool user_key = (connection.server_uri, connection.user, \ connection.password) user_connections = self.connections.setdefault(user_key, []) user_connections.append(connection) -- hilsen/regards Max M, Denmark http://www.mxm.dk/ IT's Mad Science
--On Dienstag, 26. April 2005 8:01 Uhr +0200 Max M <maxm@mxm.dk> wrote:
I am writing an Imap client. The Imap server (Groupwise) I connect to is really slow at accepting logins.
So I have made a connection pool where I store the open connections to the server.
But once in a while I get a memory segment error on the server and it crashes.
I suspect what happens is that a connection has been idle for to long, ad the connection dropped by the imap server. Which might cause some memory to be freed that is then accessed when I call noop().
So it would be (group)wise to ask the vendor (Novell)?
It could also be be some kind of threading problem.
It could be anything...servers should never crash because of client side problems.
Does any of you hav an ide as to how I can find out? I am not used to these kind of problems, having been spoiled by Python for too long.
Looking at the code I see nothing that could help from figuring out some server problems or doing some remote healing. -aj
Andreas Jung wrote:
I suspect what happens is that a connection has been idle for to long, ad the connection dropped by the imap server. Which might cause some memory to be freed that is then accessed when I call noop().
So it would be (group)wise to ask the vendor (Novell)?
Zope and Groupwise are on different machines, so I don't think I can blame Groupwise. Imap servers are supposed to loose the connection after a set time. eg. 20 minutes. It is most likely something that happens in the imap library. Perhaps a socket being freed and garbage collected, which I then try to access from the pool. My connection pooling is just a thin wrapper around the standard imap library. So I guess I should try to find the problem there.
Looking at the code I see nothing that could help from figuring out some server problems or doing some remote healing.
Ok. I will need to do some deeper debugging. Nothing is more fun than debugging something with a 20 minutes timeout :-s -- hilsen/regards Max M, Denmark http://www.mxm.dk/ IT's Mad Science
participants (2)
-
Andreas Jung -
Max M