Merge lp:~townsend/libertine/operations-counter into lp:libertine

Proposed by Christopher Townsend
Status: Merged
Approved by: Larry Price
Approved revision: 324
Merged at revision: 324
Proposed branch: lp:~townsend/libertine/operations-counter
Merge into: lp:libertine
Diff against target: 43 lines (+8/-5)
1 file modified
tools/libertine-lxc-manager (+8/-5)
To merge this branch: bzr merge lp:~townsend/libertine/operations-counter
Reviewer Review Type Date Requested Status
Libertine CI Bot continuous-integration Approve
Larry Price Approve
Review via email: mp+309774@code.launchpad.net

Commit message

Use a counter for tracking on going libertine-container-manager operations since they can occur in parallel.

To post a comment you must log in.
Revision history for this message
Larry Price (larryprice) wrote :

lgtm

review: Approve
Revision history for this message
Libertine CI Bot (libertine-ci-bot) :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'tools/libertine-lxc-manager'
--- tools/libertine-lxc-manager 2016-10-25 15:24:08 +0000
+++ tools/libertine-lxc-manager 2016-11-01 16:53:17 +0000
@@ -41,7 +41,7 @@
41 def __init__(self):41 def __init__(self):
42 self.is_pulse_setup = False42 self.is_pulse_setup = False
43 self.app_counter = Counter()43 self.app_counter = Counter()
44 self.operation_running = {}44 self.operation_counter = Counter()
4545
46 DBusGMainLoop(set_as_default=True)46 DBusGMainLoop(set_as_default=True)
47 try:47 try:
@@ -57,7 +57,7 @@
57 in_signature='ss',57 in_signature='ss',
58 out_signature='(bs)')58 out_signature='(bs)')
59 def app_start(self, container_id, lxc_logfile):59 def app_start(self, container_id, lxc_logfile):
60 if container_id in self.operation_running and self.operation_running[container_id]:60 if self.operation_counter[container_id] != 0:
61 return (False, "Libertine container operation already running: cannot launch application.")61 return (False, "Libertine container operation already running: cannot launch application.")
6262
63 (started, reason) = self._launch_lxc_container(container_id, lxc_logfile)63 (started, reason) = self._launch_lxc_container(container_id, lxc_logfile)
@@ -86,15 +86,18 @@
86 (started, reason) = self._launch_lxc_container(container_id, lxc_log_file, launchable=False)86 (started, reason) = self._launch_lxc_container(container_id, lxc_log_file, launchable=False)
8787
88 if started:88 if started:
89 self.operation_running[container_id] = True89 self.operation_counter[container_id] += 1
9090
91 return (started, reason)91 return (started, reason)
9292
93 @dbus.service.method(LIBERTINE_LXC_MANAGER_NAME,93 @dbus.service.method(LIBERTINE_LXC_MANAGER_NAME,
94 in_signature='s')94 in_signature='s')
95 def operation_stop(self, container_id):95 def operation_stop(self, container_id):
96 self._stop_lxc_container(container_id)96 self.operation_counter[container_id] -= 1
97 del self.operation_running[container_id]97
98 if self.operation_counter[container_id] == 0:
99 self._stop_lxc_container(container_id)
100 del self.operation_counter[container_id]
98101
99 def _setup_pulse(self):102 def _setup_pulse(self):
100 pulse_socket_path = os.path.join(libertine.utils.get_libertine_runtime_dir(), 'pulse_socket')103 pulse_socket_path = os.path.join(libertine.utils.get_libertine_runtime_dir(), 'pulse_socket')

Subscribers

People subscribed via source and target branches