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
1=== modified file 'tools/libertine-lxc-manager'
2--- tools/libertine-lxc-manager 2016-10-25 15:24:08 +0000
3+++ tools/libertine-lxc-manager 2016-11-01 16:53:17 +0000
4@@ -41,7 +41,7 @@
5 def __init__(self):
6 self.is_pulse_setup = False
7 self.app_counter = Counter()
8- self.operation_running = {}
9+ self.operation_counter = Counter()
10
11 DBusGMainLoop(set_as_default=True)
12 try:
13@@ -57,7 +57,7 @@
14 in_signature='ss',
15 out_signature='(bs)')
16 def app_start(self, container_id, lxc_logfile):
17- if container_id in self.operation_running and self.operation_running[container_id]:
18+ if self.operation_counter[container_id] != 0:
19 return (False, "Libertine container operation already running: cannot launch application.")
20
21 (started, reason) = self._launch_lxc_container(container_id, lxc_logfile)
22@@ -86,15 +86,18 @@
23 (started, reason) = self._launch_lxc_container(container_id, lxc_log_file, launchable=False)
24
25 if started:
26- self.operation_running[container_id] = True
27+ self.operation_counter[container_id] += 1
28
29 return (started, reason)
30
31 @dbus.service.method(LIBERTINE_LXC_MANAGER_NAME,
32 in_signature='s')
33 def operation_stop(self, container_id):
34- self._stop_lxc_container(container_id)
35- del self.operation_running[container_id]
36+ self.operation_counter[container_id] -= 1
37+
38+ if self.operation_counter[container_id] == 0:
39+ self._stop_lxc_container(container_id)
40+ del self.operation_counter[container_id]
41
42 def _setup_pulse(self):
43 pulse_socket_path = os.path.join(libertine.utils.get_libertine_runtime_dir(), 'pulse_socket')

Subscribers

People subscribed via source and target branches