On Mon, Sep 6, 2010 at 10:27, Tomeu Vizoso <to...@sugarlabs.org> wrote:
> On Fri, Sep 3, 2010 at 19:48, Martin Langhoff <mar...@laptop.org> wrote:
>> On Fri, Sep 3, 2010 at 12:43 PM, Tomeu Vizoso <to...@sugarlabs.org> wrote:
>>> I have a local XS 0.6 that is working fine but I'm finding that the XS
>>> 0.5.2 at jabber.sugarlabs.org is not returning some results for some
>>> of the queries that I make.
>>
>> There are very important bugfixes in the "final" ejabberd that is in
>> olpcxs-testing repo for xs-0.6
>>
>> I should release a 0.6.1 with the contents of olpcxs-testing, but
>> things haven't been kind to me lately.
>>
>> You aren't telling us exactly what problems you saw on the old
>> ejabberd.
>
> I'm noticing that the server never replies to some PEP queries about
> buddyinfo and activity properties. The symptom on the Sugar side is
> that the DBus calls timeout.

Actually, it eventually replies, it's just that it takes veeery long sometimes.

With the script attached, some GetProperties queries take a few
seconds, others more than 25 seconds (the default dbus timeout). It
should be invoked like this: dbus-launch --exit-with-session python
gabble_test.py

There are presently 2573 registered users and the ejabberd version is
ejabberd-xs-2.0.3-11.fc9.olpc.i386 , which is the last one I see in
http://fedora.laptop.org/xs/testing/olpc/9/i386/

Martin, does it match your experience that, when there are several
hundreds of registered users, PEP queries could take so much CPU?
During each query, the process 'beam' was taking 100% CPU. Postgres
didn't appeared in top.

Thanks,

Tomeu

>> All I can say is: that old ejabberd (+patches) had plenty of
>> gremlins and unexplainable behaviours. The ejabberd in olpcxs-testing
>> has been 100% reliable in behaviour, and I reworked the patches until
>> I didn't see any buggy behaviour.
>
> Thanks, this answers perfectly my question.
>
>> Highly recommended. Should work with just a rebuild if you're not on F9.
>>
>> I cannot confirm that the right patches are in the latest ejabberd on F13.
>
> Ok, will be keeping an eye on further updates to the School Server
> software and will test Sugar against its jabber server.
>
>> cheers,
>>
>>
>> m
>> --
>>  mar...@laptop.org -- School Server Architect
>>  - ask interesting questions
>>  - don't get distracted with shiny stuff  - working code first
>>  - http://wiki.laptop.org/go/User:Martinlanghoff
>>
>
from functools import partial
import logging

import gobject
import dbus
import dbus.mainloop.glib
import telepathy

from dbus import PROPERTIES_IFACE
from telepathy.interfaces import ACCOUNT, \
                                 ACCOUNT_MANAGER, \
                                 CONNECTION, \
                                 CHANNEL, \
                                 CHANNEL_INTERFACE_GROUP, \
                                 CONNECTION_INTERFACE_REQUESTS, \
                                 CONNECTION_INTERFACE_ALIASING, \
                                 CONNECTION_INTERFACE_CONTACTS, \
                                 CHANNEL_TYPE_CONTACT_LIST
from telepathy.constants import HANDLE_TYPE_LIST

ACCOUNT_MANAGER_SERVICE = 'org.freedesktop.Telepathy.AccountManager'
ACCOUNT_MANAGER_PATH = '/org/freedesktop/Telepathy/AccountManager'

CONNECTION_INTERFACE_BUDDY_INFO = 'org.laptop.Telepathy.BuddyInfo'
CONNECTION_INTERFACE_ACTIVITY_PROPERTIES = \
        'org.laptop.Telepathy.ActivityProperties'

dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
main_loop = gobject.MainLoop()

connection = None

def _account_property_changed_cb(account_path, properties):
    if 'ConnectionStatus' not in properties:
        return
    if properties['ConnectionStatus'] == 0:
        bus = dbus.Bus()
        obj = bus.get_object(ACCOUNT_MANAGER_SERVICE, account_path)
        connection_path = obj.Get(ACCOUNT, 'Connection', dbus_interface=PROPERTIES_IFACE)

        connection_name = connection_path.replace('/', '.')[1:]
        
        global connection
        connection = bus.get_object(connection_name, connection_path)

        properties = {
                CHANNEL + '.ChannelType': CHANNEL_TYPE_CONTACT_LIST,
                CHANNEL + '.TargetHandleType': HANDLE_TYPE_LIST,
                CHANNEL + '.TargetID': 'subscribe',
                }
        properties = dbus.Dictionary(properties, signature='sv')
        is_ours, channel_path, properties = \
                connection.EnsureChannel(properties,
                                         dbus_interface=CONNECTION_INTERFACE_REQUESTS)

        channel = bus.get_object(connection_name, channel_path)
        channel.connect_to_signal('MembersChanged', _members_changed_cb)

        channel.Get(CHANNEL_INTERFACE_GROUP,
                    'Members',
                    reply_handler=_get_members_ready_cb,
                    error_handler=partial(_error_handler_cb,
                                          'Connection.GetMembers'),
                    dbus_interface=PROPERTIES_IFACE)

def _members_changed_cb(message, added, removed, local_pending,
                         remote_pending, actor, reason):
    _add_handles(added)

def _get_members_ready_cb(handles):
    _add_handles(handles)

def _error_handler_cb(function_name, error):
    raise RuntimeError('Error when calling %s: %s' % (function_name, error))

def _get_contact_attributes_cb(attributes):
    successful_tries = 0
    for handle in attributes.keys():
        import time
        print '==================== asking for properties for handle %r with alias %s' % (handle, attributes[handle][CONNECTION_INTERFACE_ALIASING + '/alias'])
        initial_time = time.time()
        try:
            properties = connection.GetProperties(handle, byte_arrays=True, dbus_interface=CONNECTION_INTERFACE_BUDDY_INFO,
                                                  timeout=100)
        except dbus.exceptions.DBusException, e:
            print '==================== failed to get properties for handle %r in %f s. with error %r\n\n' % (handle, time.time() - initial_time, e)
        else:
            print '==================== got properties for handle %r in %f s.\n\n' % (handle, time.time() - initial_time)
            successful_tries += 1

    print 'succeeded %d tries of a total of %d' % (successful_tries, len(attributes))
    main_loop.quit()

def _add_handles(handles):
    if not handles:
        return
    interfaces = [CONNECTION, CONNECTION_INTERFACE_ALIASING]
    attributes = connection.GetContactAttributes(
            handles, interfaces, False,
            reply_handler=_get_contact_attributes_cb,
            error_handler=partial(_error_handler_cb,
                                  'Connection.GetMembers'),
            dbus_interface=CONNECTION_INTERFACE_CONTACTS)


bus = dbus.Bus()
obj = bus.get_object(ACCOUNT_MANAGER_SERVICE, ACCOUNT_MANAGER_PATH)
account_manager = dbus.Interface(obj, ACCOUNT_MANAGER)
account_paths = account_manager.Get(ACCOUNT_MANAGER, 'ValidAccounts',
                                    dbus_interface=PROPERTIES_IFACE)
for account_path in account_paths:
    if 'gabble' in account_path:
        obj = bus.get_object(ACCOUNT_MANAGER_SERVICE, account_path)
        obj.connect_to_signal(
            'AccountPropertyChanged',
            partial(_account_property_changed_cb, account_path))

main_loop.run()
_______________________________________________
Sugar-devel mailing list
Sugar-devel@lists.sugarlabs.org
http://lists.sugarlabs.org/listinfo/sugar-devel

Reply via email to