diff options
author | John (J5) Palmieri <johnp@redhat.com> | 2005-08-26 03:09:59 +0000 |
---|---|---|
committer | John (J5) Palmieri <johnp@redhat.com> | 2005-08-26 03:09:59 +0000 |
commit | 64e468d21ce306831ff8ab76f6704b1ffdafbea2 (patch) | |
tree | ba8b8501e2cfdf8f3b0fe4307478ec35005b29e7 | |
parent | c2ff73e5c695b538404b96f0f77eaabefc8cb3d7 (diff) |
* python/dbus_bindings.pyx: Tracked down a major memleak and fixed it
(EmptyMessage): new class that subclasses Message. This is a workaround
to a Pyrex bug that fails to call __del__ when the Message object goes out
of scope. For some reason subclassing Message fixes this bug
(Bus::send_with_reply_and_block): use EmptyMessage instead of Message
-rw-r--r-- | ChangeLog | 8 | ||||
-rw-r--r-- | python/dbus_bindings.pyx | 36 | ||||
-rw-r--r-- | python/proxies.py | 2 |
3 files changed, 29 insertions, 17 deletions
@@ -1,3 +1,11 @@ +2005-08-25 John (J5) Palmieri <johnp@redhat.com> + + * python/dbus_bindings.pyx: Tracked down a major memleak and fixed it + (EmptyMessage): new class that subclasses Message. This is a workaround + to a Pyrex bug that fails to call __del__ when the Message object goes out + of scope. For some reason subclassing Message fixes this bug + (Bus::send_with_reply_and_block): use EmptyMessage instead of Message + 2005-08-25 Colin Walters <walters@verbum.org> * glib/dbus-gproxy.c (dbus_g_proxy_call): Doc update, thanks diff --git a/python/dbus_bindings.pyx b/python/dbus_bindings.pyx index a083f504..93a94733 100644 --- a/python/dbus_bindings.pyx +++ b/python/dbus_bindings.pyx @@ -359,7 +359,7 @@ cdef class Connection: return (retval, pending_call) def send_with_reply_and_block(self, Message message, - timeout_milliseconds=0): + timeout_milliseconds=-1): cdef DBusMessage * retval cdef DBusError error cdef DBusMessage *msg @@ -381,9 +381,10 @@ cdef class Connection: if retval == NULL: raise AssertionError - m = Message(_create=0) + m = EmptyMessage() m._set_msg(retval) - return m + + return m def set_watch_functions(self, add_function, remove_function, data): pass @@ -1255,19 +1256,18 @@ cdef class Message: if (service != None): cservice = service - if not _create: - return - - if message_type == MESSAGE_TYPE_METHOD_CALL: - self.msg = dbus_message_new_method_call(cservice, path, ciface, method) - elif message_type == MESSAGE_TYPE_METHOD_RETURN: - cmsg = method_call._get_msg() - self.msg = dbus_message_new_method_return(cmsg) - elif message_type == MESSAGE_TYPE_SIGNAL: - self.msg = dbus_message_new_signal(path, ciface, name) - elif message_type == MESSAGE_TYPE_ERROR: - cmsg = reply_to._get_msg() - self.msg = dbus_message_new_error(cmsg, error_name, error_message) + if _create: + if message_type == MESSAGE_TYPE_METHOD_CALL: + self.msg = dbus_message_new_method_call(cservice, path, ciface, method) + elif message_type == MESSAGE_TYPE_METHOD_RETURN: + cmsg = method_call._get_msg() + self.msg = dbus_message_new_method_return(cmsg) + elif message_type == MESSAGE_TYPE_SIGNAL: + self.msg = dbus_message_new_signal(path, ciface, name) + elif message_type == MESSAGE_TYPE_ERROR: + cmsg = reply_to._get_msg() + self.msg = dbus_message_new_error(cmsg, error_name, error_message) + def __del__(self): if self.msg != NULL: @@ -1439,6 +1439,10 @@ class Signal(Message): def __init__(self, spath, sinterface, sname): Message.__init__(self, MESSAGE_TYPE_SIGNAL, path=spath, dbus_interface=sinterface, name=sname) +class EmptyMessage(Message): + def __init__(self): + Message.__init__(self, _create=False) + class MethodCall(Message): def __init__(self, mpath, minterface, mmethod): Message.__init__(self, MESSAGE_TYPE_METHOD_CALL, path=mpath, dbus_interface=minterface, method=mmethod) diff --git a/python/proxies.py b/python/proxies.py index 42866426..f41a8de1 100644 --- a/python/proxies.py +++ b/python/proxies.py @@ -63,7 +63,7 @@ class ProxyMethod: else: reply_message = self._connection.send_with_reply_and_block(message, timeout) args_tuple = reply_message.get_args_list() - + if len(args_tuple) == 0: return elif len(args_tuple) == 1: |