Merge lp://staging/~tealeg/landscape-client/catch-unreachable-server into lp://staging/~landscape/landscape-client/trunk

Proposed by Geoff Teale
Status: Merged
Approved by: Thomas Herve
Approved revision: 492
Merged at revision: 491
Proposed branch: lp://staging/~tealeg/landscape-client/catch-unreachable-server
Merge into: lp://staging/~landscape/landscape-client/trunk
Diff against target: 191 lines (+90/-16)
5 files modified
landscape/ui/controller/app.py (+14/-11)
landscape/ui/controller/configuration.py (+3/-1)
landscape/ui/controller/tests/test_app.py (+2/-1)
landscape/ui/model/registration/proxy.py (+13/-3)
landscape/ui/model/registration/tests/test_proxy.py (+58/-0)
To merge this branch: bzr merge lp://staging/~tealeg/landscape-client/catch-unreachable-server
Reviewer Review Type Date Requested Status
Thomas Herve (community) Approve
Free Ekanayaka (community) Approve
Review via email: mp+96767@code.staging.launchpad.net

Description of the change

Fixes bug #949208.

This branch catches the offending timeout exception and changed the register call to always be synchronous as the asynchronous call backs are lost under failure conditions.

There is also a small fix to the use of Notify that was previously masked by the lost callback problem.

To post a comment you must log in.
Revision history for this message
Free Ekanayaka (free.ekanayaka) wrote :

[1]

         self._register_handlers()
         if self._bus:
- return self._interface.register(config_path,
- reply_handler=reply_handler,
- error_handler=error_handler)
+ try:
+ result, message = self._interface.register(config_path)
+ except dbus.DBusException, e:
+ if e.get_dbus_name() != "org.freedesktop.DBus.Error.NoReply":
+ raise
+ else:
+ error_handler("Registration timed out.")
+ if result:

The "result" variable will be undefined if error_handler() is called, and indeed TimeoutTest.test_register fails:

landscape.ui.model.registration.tests.test_proxy
  TimeoutTest
    test_register ... [ERROR]

===============================================================================
[ERROR]
Traceback (most recent call last):
  File "/home/free/src/client/trunk/landscape/tests/mocker.py", line 146, in test_method_wrapper
    result = test_method()
  File "/home/free/src/client/trunk/landscape/ui/model/registration/tests/test_proxy.py", line 64, in test_register
    self.proxy.register("foo", error_handler=fake_error_handler)
  File "/home/free/src/client/trunk/landscape/ui/model/registration/proxy.py", line 116, in register
    if result:
exceptions.UnboundLocalError: local variable 'result' referenced before assignment

landscape.ui.model.registration.tests.test_proxy.TimeoutTest.test_register
-------------------------------------------------------------------------------
Ran 1 tests in 0.003s

review: Needs Fixing
Revision history for this message
Geoff Teale (tealeg) wrote :

> [1]
>
> self._register_handlers()
> if self._bus:
> - return self._interface.register(config_path,
> - reply_handler=reply_handler,
> - error_handler=error_handler)
> + try:
> + result, message = self._interface.register(config_path)
> + except dbus.DBusException, e:
> + if e.get_dbus_name() != "org.freedesktop.DBus.Error.NoReply":
> + raise
> + else:
> + error_handler("Registration timed out.")
> + if result:
>
> The "result" variable will be undefined if error_handler() is called, and
> indeed TimeoutTest.test_register fails:
>
>
> landscape.ui.model.registration.tests.test_proxy
> TimeoutTest
> test_register ...
> [ERROR]
>
> ==============================================================================
> =
> [ERROR]
> Traceback (most recent call last):
> File "/home/free/src/client/trunk/landscape/tests/mocker.py", line 146, in
> test_method_wrapper
> result = test_method()
> File "/home/free/src/client/trunk/landscape/ui/model/registration/tests/test
> _proxy.py", line 64, in test_register
> self.proxy.register("foo", error_handler=fake_error_handler)
> File "/home/free/src/client/trunk/landscape/ui/model/registration/proxy.py",
> line 116, in register
> if result:
> exceptions.UnboundLocalError: local variable 'result' referenced before
> assignment
>
> landscape.ui.model.registration.tests.test_proxy.TimeoutTest.test_register
> ------------------------------------------------------------------------------
> -
> Ran 1 tests in 0.003s

Yup - quite right. Now fixed.

491. By Geoff Teale

Make sure result variable is set even when an error occurs. From Free's review.

Revision history for this message
Free Ekanayaka (free.ekanayaka) wrote :

+1!

[2]

+ RegistrationProxy._setup_interface = fake_setup_interface
+ RegistrationProxy._register_handlers = fake_register_handlers
+ RegistrationProxy._remove_handlers = fake_remove_handlers

I believe you need to monkey patch the class instead of the instance because of the self._setup_interface(bus) call in RegistrationProxy.__init__() ?

This is unfortunate, I think RegistrationProxy should rather have a setup() method that you call explicitly to connect to DBus.

Also, the original method of the RegistrationProxy are not restored, so running these tests has (possibly nasty) side effects. I've noticed RegistrationProxyTest does something similar.

Just thought I'd mention it, we can live with this for now and surely it's something for another branch.

review: Approve
492. By Geoff Teale

Merged forward trunk

Revision history for this message
Thomas Herve (therve) wrote :

Looks good, +1.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
The diff is not available at this time. You can reload the page or download it.

Subscribers

People subscribed via source and target branches

to all changes: