Merge ~cjwatson/launchpad:py3-command-spawner into launchpad:master

Proposed by Colin Watson
Status: Merged
Approved by: Colin Watson
Approved revision: 490a5f99d26a856f45f159941ab6fbb4923ef17c
Merge reported by: Otto Co-Pilot
Merged at revision: not available
Proposed branch: ~cjwatson/launchpad:py3-command-spawner
Merge into: launchpad:master
Diff against target: 26 lines (+2/-2)
2 files modified
lib/lp/services/command_spawner.py (+1/-1)
lib/lp/services/tests/test_command_spawner.py (+1/-1)
Reviewer Review Type Date Requested Status
Ioana Lasc (community) Approve
Review via email: mp+393814@code.launchpad.net

Commit message

Fix CommandSpawner on Python 3

Description of the change

We only ever use this for logging textual output, so just unconditionally treat process output as text rather than bothering to make it optional.

To post a comment you must log in.
Revision history for this message
Ioana Lasc (ilasc) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/lib/lp/services/command_spawner.py b/lib/lp/services/command_spawner.py
2index 988110c..98bcc1d 100644
3--- a/lib/lp/services/command_spawner.py
4+++ b/lib/lp/services/command_spawner.py
5@@ -158,7 +158,7 @@ class CommandSpawner:
6 """Spawn a sub-process for `command`. Overridable in tests."""
7 return subprocess.Popen(
8 command, stdout=subprocess.PIPE, stderr=subprocess.PIPE,
9- close_fds=True)
10+ close_fds=True, universal_newlines=True)
11
12 def _handle(self, process, event, *args):
13 """If we have a handler for `event` on `process`, call it."""
14diff --git a/lib/lp/services/tests/test_command_spawner.py b/lib/lp/services/tests/test_command_spawner.py
15index 12ccb7a..c7cc06c 100644
16--- a/lib/lp/services/tests/test_command_spawner.py
17+++ b/lib/lp/services/tests/test_command_spawner.py
18@@ -97,7 +97,7 @@ class TestCommandSpawner(TestCase):
19 def test_start_adds_a_process(self):
20 spawner, process = self._makeSpawnerAndProcess()
21 spawner.start("/bin/true")
22- self.assertEqual([process], spawner.running_processes.keys())
23+ self.assertEqual([process], list(spawner.running_processes))
24
25 def test_start_runs_its_command(self):
26 spawner, process = self._makeSpawnerAndProcess()

Subscribers

People subscribed via source and target branches

to status/vote changes: