Merge lp:~alecu/ubuntu-sso-client/fix-disconnected-removal into lp:ubuntu-sso-client

Proposed by Alejandro J. Cura
Status: Merged
Approved by: Roberto Alsina
Approved revision: 769
Merged at revision: 769
Proposed branch: lp:~alecu/ubuntu-sso-client/fix-disconnected-removal
Merge into: lp:ubuntu-sso-client
Diff against target: 73 lines (+27/-2)
3 files modified
run-tests.bat (+1/-1)
ubuntu_sso/main/tests/test_windows.py (+22/-0)
ubuntu_sso/main/windows.py (+4/-1)
To merge this branch: bzr merge lp:~alecu/ubuntu-sso-client/fix-disconnected-removal
Reviewer Review Type Date Requested Status
Manuel de la Peña (community) Approve
Natalia Bidart (community) Approve
Review via email: mp+72988@code.launchpad.net

Commit message

- Do not remove a dead IPC client while iterating the list of clients. (LP: #834224).

Description of the change

Do not remove a dead IPC client while iterating the list of clients. (LP: #834224)

To post a comment you must log in.
Revision history for this message
Natalia Bidart (nataliabidart) wrote :

Looks great!

Before landing, please change "Returns" by "Return" in:

"""Returns a succeed."""

review: Approve
Revision history for this message
Manuel de la Peña (mandel) :
review: Approve
Revision history for this message
Ubuntu One Auto Pilot (otto-pilot) wrote :

The attempt to merge lp:~alecu/ubuntu-sso-client/fix-disconnected-removal into lp:ubuntu-sso-client failed. Below is the output from the failed tests.

Running test suite for ubuntu_sso
ubuntu_sso.xdg_base_directory.tests.test_common
  TestBaseDirectory
    test_load_config_paths_filter ... [OK]
    test_save_config_path ... [OK]
    test_xdg_cache_home_is_bytes ... [OK]
    test_xdg_data_home_is_bytes ... [OK]
twisted.trial.unittest
  TestCase
    runTest ... [OK]
ubuntu_sso.gtk.tests.test_gui
  BasicTestCase
    runTest ... [OK]
  BasicUbuntuSSOClientTestCase
    test_app_name_is_stored ...
/usr/lib/python2.7/dist-packages/gtk-2.0/gtk/__init__.py:57: GtkWarning: could not open display
  warnings.warn(str(e), _gtk.Warning)
./run-tests: line 57: 21480 Floating point exception(core dumped) `which xvfb-run` u1trial -p "$QT_TESTS_PATH" -i "test_windows.py" "$MODULE"

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'run-tests.bat'
2--- run-tests.bat 2011-07-25 14:45:33 +0000
3+++ run-tests.bat 2011-08-26 04:35:30 +0000
4@@ -55,7 +55,7 @@
5 "%PYTHONEXEPATH%\python.exe" setup.py build
6 ECHO Running tests
7 :: execute the tests with a number of ignored linux only modules
8-"%PYTHONEXEPATH%\python.exe" "%PYTHONEXEPATH%\Scripts\u1trial" -c ubuntu_sso -i "test_gui.py, test_linux.py, test_txsecrets.py" --reactor=qt4 --gui
9+"%PYTHONEXEPATH%\python.exe" "%PYTHONEXEPATH%\Scripts\u1trial" -c ubuntu_sso -i "test_gui.py, test_linux.py, test_txsecrets.py" --reactor=qt4 --gui %*
10 :: Clean the build from the setupt.py
11 ECHO Cleaning the generated code before running the style checks...
12 "%PYTHONEXEPATH%\python.exe" setup.py clean
13
14=== modified file 'ubuntu_sso/main/tests/test_windows.py'
15--- ubuntu_sso/main/tests/test_windows.py 2011-08-22 16:21:36 +0000
16+++ ubuntu_sso/main/tests/test_windows.py 2011-08-26 04:35:30 +0000
17@@ -163,6 +163,18 @@
18 raise DeadReferenceError("Calling Stale Broker")
19
20
21+class FakeAliveRemoteClient(object):
22+ """A fake alive remote client."""
23+
24+ def __init__(self):
25+ self.called = False
26+
27+ def callRemote(self, signal_name, *args, **kwargs):
28+ """Returns a succeed."""
29+ self.called = True
30+ return defer.succeed(None)
31+
32+
33 class SignalBroadcasterTestCase(TestCase):
34 """Test the SignalBroadcaster class."""
35
36@@ -175,6 +187,16 @@
37 sb.emit_signal("sample_signal")
38 self.assertNotIn(fake_remote_client, sb.clients)
39
40+ def test_emit_signal_some_dead_some_not(self):
41+ """Test a clean reference after a dead one."""
42+ fake_dead_remote = FakeDeadRemoteClient()
43+ fake_alive_remote = FakeAliveRemoteClient()
44+ sb = SignalBroadcaster()
45+ sb.remote_register_to_signals(fake_dead_remote)
46+ sb.remote_register_to_signals(fake_alive_remote)
47+ sb.emit_signal("sample_signal")
48+ self.assertTrue(fake_alive_remote.called, "The alive must be called.")
49+
50
51 class SSOLoginTestCase(TestCase):
52 """Test the login class."""
53
54=== modified file 'ubuntu_sso/main/windows.py'
55--- ubuntu_sso/main/windows.py 2011-08-24 14:39:52 +0000
56+++ ubuntu_sso/main/windows.py 2011-08-26 04:35:30 +0000
57@@ -171,12 +171,15 @@
58
59 def emit_signal(self, signal_name, *args, **kwargs):
60 """Emit the given signal to the clients."""
61+ dead_clients = []
62 for current_client in self.clients:
63 try:
64 d = current_client.callRemote(signal_name, *args, **kwargs)
65 d.addErrback(self._emit_failure)
66 except DeadReferenceError:
67- self.remote_unregister_to_signals(current_client)
68+ dead_clients.append(current_client)
69+ for client in dead_clients:
70+ self.remote_unregister_to_signals(client)
71
72
73 class SSOLogin(Referenceable, SignalBroadcaster):

Subscribers

People subscribed via source and target branches