Merge lp:~mandel/ubuntu-sso-client/cannot_shutdown_windows into lp:ubuntu-sso-client

Proposed by Manuel de la Peña
Status: Merged
Approved by: Natalia Bidart
Approved revision: 713
Merged at revision: 713
Proposed branch: lp:~mandel/ubuntu-sso-client/cannot_shutdown_windows
Merge into: lp:ubuntu-sso-client
Diff against target: 49 lines (+19/-4)
1 file modified
bin/windows-ubuntu-sso-login (+19/-4)
To merge this branch: bzr merge lp:~mandel/ubuntu-sso-client/cannot_shutdown_windows
Reviewer Review Type Date Requested Status
Natalia Bidart (community) Approve
Shane Fagan (community) Approve
Review via email: mp+59833@code.launchpad.net

Commit message

Updated the way in which the service shutsdowns. The implementation uses a LoopingCallback from twisted and does perform a correct exit which was missing in the previous code.

Description of the change

Updated the way in which the service shutsdowns. The implementation uses a LoopingCallback from twisted and does perform a correct exit which was missing in the previous code.

To post a comment you must log in.
Revision history for this message
Shane Fagan (shanepatrickfagan) :
review: Approve
Revision history for this message
Natalia Bidart (nataliabidart) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'bin/windows-ubuntu-sso-login'
2--- bin/windows-ubuntu-sso-login 2011-04-13 16:36:12 +0000
3+++ bin/windows-ubuntu-sso-login 2011-05-23 15:39:08 +0000
4@@ -36,6 +36,7 @@
5 from PyQt4.QtGui import QApplication
6 from twisted.internet import reactor
7 from twisted.spread.pb import PBServerFactory
8+from twisted.internet.task import LoopingCall
9
10 from ubuntu_sso.main.windows import (
11 CredentialsManagement,
12@@ -46,6 +47,18 @@
13 UbuntuSSORoot)
14
15
16+def add_timeout(interval, callback, *args, **kwargs):
17+ """Add a timeout callback as a task."""
18+ time_out_task = LoopingCall(callback, *args, **kwargs)
19+ time_out_task.start(interval/1000, now=False)
20+
21+
22+def shutdown(pipe_service):
23+ """Shutdown all the running processes and threads."""
24+ pipe_service.stop()
25+ reactor.stop()
26+
27+
28 if __name__ == '__main__':
29 # check if the service is running by calling the named pipe, if not
30 # start it.
31@@ -53,12 +66,14 @@
32 if port is None:
33 login = SSOLogin('ignored')
34 creds = SSOCredentials()
35- creds_management = CredentialsManagement(lambda:None, sys.exit)
36+ username = GetUserNameEx(NameSamCompatible)
37+ named_pipe_service = ListeningPortPipeService(username,
38+ 0)
39+ creds_management = CredentialsManagement(add_timeout,
40+ lambda: shutdown(named_pipe_service))
41 root = UbuntuSSORoot(login, creds, creds_management)
42 listener = reactor.listenTCP(0, PBServerFactory(root))
43- username = GetUserNameEx(NameSamCompatible)
44- named_pipe_service = ListeningPortPipeService(username,
45- listener.getHost().port)
46+ named_pipe_service.port = listener.getHost().port
47 service_thread = Thread(name='Ubuntu SSO Port Broadcaster',
48 target=named_pipe_service.start)
49 service_thread.start()

Subscribers

People subscribed via source and target branches