[Zope] Memorysegment error in Zope

2005-04-26 Thread Max M
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
___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
http://mail.zope.org/mailman/listinfo/zope-announce
http://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] Memorysegment error in Zope

2005-04-26 Thread Andreas Jung

--On Dienstag, 26. April 2005 8:01 Uhr +0200 Max M [EMAIL PROTECTED] 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

pgpJAhkt4y9dX.pgp
Description: PGP signature
___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )