~mvo/ubuntu-sso-client/strawman-lp711413

« back to all changes in this revision

Viewing changes to ubuntu_sso/main/linux.py

  • Committer: Michael Vogt
  • Date: 2012-05-23 14:51:10 UTC
  • Revision ID: michael.vogt@ubuntu.com-20120523145110-sasgx14uky11l2fh
cleanup and add test, thanks to Natalia for the initial review

Show diffs side-by-side

added added

removed removed

Lines of Context:
39
39
"""
40
40
 
41
41
import signal
 
42
import time
42
43
 
43
44
import dbus
44
45
import dbus.service
45
 
import time
46
46
 
47
47
from twisted.internet import defer
48
48
 
64
64
logger = setup_logging("ubuntu_sso.main.linux")
65
65
 
66
66
 
 
67
# the time and retry count to wait for the session bus to become
 
68
# available before the system errors out
 
69
DBUS_RETRY_WAIT_TIME = 0.2
 
70
DBUS_RETRY_COUNT_MAX = 10
 
71
 
 
72
 
67
73
class SSOLoginProxy(dbus.service.Object):
68
74
    """Login thru the Single Sign On service."""
69
75
 
351
357
    def bus(self):
352
358
        if self._bus is None:
353
359
            # keep retrying to avoid race on login/logout, see LP: #711413
354
 
            for i in range(10):
 
360
            for i in range(DBUS_RETRY_COUNT_MAX):
355
361
                try:
356
362
                    self._bus = dbus.SessionBus()
357
363
                    break
358
 
                except dbus.DBusException as e:
359
 
                    time.sleep(0.2)
 
364
                except dbus.DBusException:
 
365
                    logger.exception("Failed to get the session dbus""")
 
366
                    time.sleep(DBUS_RETRY_WAIT_TIME)
360
367
        return self._bus
361
368
 
362
369
    def start(self):