Skip to content

Commit d18a240

Browse files
committed
Fix for CONPY-220:
Added _get_socket method (for internal use only)
1 parent 336bf34 commit d18a240

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

mariadb/connections.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -652,7 +652,7 @@ def autocommit(self, mode):
652652
def socket(self):
653653
"""Returns the socket used for database connection"""
654654

655-
fno = self.get_socket()
655+
fno = self._get_socket()
656656
if not self._socket:
657657
self._socket = socket.socket(fileno=fno)
658658
# in case of a possible reconnect, file descriptor has changed

mariadb/mariadb_connection.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,9 @@ MrdbConnection_executecommand(MrdbConnection *self,
8080
static PyObject *
8181
MrdbConnection_readresponse(MrdbConnection *self);
8282

83+
static PyObject
84+
*MrdbConnection_socket(MrdbConnection *self);
85+
8386
static PyGetSetDef
8487
MrdbConnection_sets[]=
8588
{
@@ -154,6 +157,9 @@ MrdbConnection_Methods[] =
154157
{"_mariadb_get_info", (PyCFunction)MrdbConnection_getinfo,
155158
METH_VARARGS,
156159
"For internal use only"},
160+
{"_get_socket", (PyCFunction)MrdbConnection_socket,
161+
METH_NOARGS,
162+
"For internal use only"},
157163
{NULL} /* always last */
158164
};
159165

@@ -890,6 +896,13 @@ static PyObject *MrdbConnection_readresponse(MrdbConnection *self)
890896
Py_RETURN_NONE;
891897
}
892898

899+
static PyObject *MrdbConnection_socket(MrdbConnection *self)
900+
{
901+
MARIADB_CHECK_CONNECTION(self, NULL);
902+
903+
return PyLong_FromLong((unsigned long)mysql_get_socket(self->mysql));
904+
}
905+
893906
/* vim: set tabstop=4 */
894907
/* vim: set shiftwidth=4 */
895908
/* vim: set expandtab */

0 commit comments

Comments
 (0)