Merge lp:~abentley/launchpad/twisted-environ into lp:launchpad

Proposed by Aaron Bentley
Status: Merged
Merged at revision: not available
Proposed branch: lp:~abentley/launchpad/twisted-environ
Merge into: lp:launchpad
Diff against target: 21 lines (+6/-4)
1 file modified
lib/lp/services/job/runner.py (+6/-4)
To merge this branch: bzr merge lp:~abentley/launchpad/twisted-environ
Reviewer Review Type Date Requested Status
Paul Hummer (community) code Approve
Review via email: mp+18626@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Aaron Bentley (abentley) wrote :

= Summary =
Fix environment variable handling in twisted job runner.

== Proposed fix ==
The twisted job runner must run a subprocess, and preserve PATH, PYTHONPATH,
and LPCONFIG. But LPCONFIG is an optional environment variable, so it should
be provided to the subprocess only when provided to the main process.

== Pre-implementation notes ==
None

== Implementation details ==
None

== Tests ==
None. This fix only applies to interactive use, and not the test environment.
In the test environment, LPCONFIG is always specified.

== Demo and Q/A ==
cronscripts/update_preview_diff --twisted

If this doesn't give a KeyError, it worked.

= Launchpad lint =

Checking for conflicts. and issues in doctests and templates.
Running jslint, xmllint, pyflakes, and pylint.
Using normal rules.

Linting changed files:
  lib/lp/services/job/runner.py

== Pylint notices ==

lib/lp/services/job/runner.py
    35: [F0401] Unable to import 'lazr.delegates' (No module named delegates)

Revision history for this message
Paul Hummer (rockstar) :
review: Approve (code)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'lib/lp/services/job/runner.py'
--- lib/lp/services/job/runner.py 2010-02-03 22:43:51 +0000
+++ lib/lp/services/job/runner.py 2010-02-04 20:02:17 +0000
@@ -287,11 +287,13 @@
287 """Run Jobs via twisted."""287 """Run Jobs via twisted."""
288288
289 def __init__(self, job_source, logger=None, error_utility=None):289 def __init__(self, job_source, logger=None, error_utility=None):
290 env = {'PYTHONPATH': os.environ['PYTHONPATH'],
291 'PATH': os.environ['PATH']}
292 lp_config = os.environ.get('LPCONFIG')
293 if lp_config is not None:
294 env['LPCONFIG'] = lp_config
290 starter = main.ProcessStarter(295 starter = main.ProcessStarter(
291 packages=('twisted', 'ampoule'),296 packages=('twisted', 'ampoule'), env=env)
292 env={'PYTHONPATH': os.environ['PYTHONPATH'],
293 'PATH': os.environ['PATH'],
294 'LPCONFIG': os.environ['LPCONFIG']})
295 super(TwistedJobRunner, self).__init__(logger, error_utility)297 super(TwistedJobRunner, self).__init__(logger, error_utility)
296 self.job_source = job_source298 self.job_source = job_source
297 import_name = '%s.%s' % (299 import_name = '%s.%s' % (