Changeset: 2e0d2ee4a592 for MonetDB URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=2e0d2ee4a592 Modified Files: clients/python/monetdb/mapi2.py clients/python/monetdb/mapi3.py clients/python/monetdb/sql/connections.py Branch: Jul2012 Log Message:
removed MSG_WAITALL so connection is terminated when server dies. Also added connection.settimeout() to make it more obvious how to set a timeout diffs (76 lines): diff --git a/clients/python/monetdb/mapi2.py b/clients/python/monetdb/mapi2.py --- a/clients/python/monetdb/mapi2.py +++ b/clients/python/monetdb/mapi2.py @@ -31,11 +31,6 @@ from cStringIO import StringIO from monetdb.monetdb_exceptions import * -# Windows doesn't support MSG_WAITALL flag for recv -flags = 0 -if hasattr(socket, 'MSG_WAITALL'): - flags = socket.MSG_WAITALL - logger = logging.getLogger("monetdb") MAX_PACKAGE_LENGTH = (1024*8)-2 @@ -232,7 +227,7 @@ class Server: count = bytes while count > 0: try: - recv = self.socket.recv(bytes, flags) + recv = self.socket.recv(bytes) logger.debug("II: package size: %i payload: %s" % (len(recv), recv)) except socket.error, error: raise OperationalError(error[1]) diff --git a/clients/python/monetdb/mapi3.py b/clients/python/monetdb/mapi3.py --- a/clients/python/monetdb/mapi3.py +++ b/clients/python/monetdb/mapi3.py @@ -31,11 +31,6 @@ from io import BytesIO from monetdb.monetdb_exceptions import * -# Windows doesn't support MSG_WAITALL flag for recv -flags = 0 -if hasattr(socket, 'MSG_WAITALL'): - flags = socket.MSG_WAITALL - logger = logging.getLogger("monetdb") MAX_PACKAGE_LENGTH = (1024*8)-2 @@ -238,7 +233,7 @@ class Server: count = bytes while count > 0: try: - recv = self.socket.recv(bytes, flags) + recv = self.socket.recv(bytes) logger.debug("II: package size: %i payload: %s" % (len(recv), recv)) except socket.error as error: raise OperationalError(error[1]) diff --git a/clients/python/monetdb/sql/connections.py b/clients/python/monetdb/sql/connections.py --- a/clients/python/monetdb/sql/connections.py +++ b/clients/python/monetdb/sql/connections.py @@ -132,7 +132,6 @@ class Connection: #return self.execute('ROLLBACK') - def cursor(self): """ Return a new Cursor Object using the connection. If the @@ -161,6 +160,16 @@ class Connection: return True + def settimeout(self,timeout): + """ set the amount of time before a connection times out """ + self.mapi.socket.settimeout(timeout) + + + def gettimeout(self): + """ get the amount of time before a connection times out """ + return self.mapi.socket.gettimeout() + + # these are required by the python DBAPI Warning = Warning Error = Error _______________________________________________ Checkin-list mailing list Checkin-list@monetdb.org http://mail.monetdb.org/mailman/listinfo/checkin-list