Merge lp:~jml/pkgme/pickleable-exceptions into lp:pkgme

Proposed by Jonathan Lange
Status: Merged
Merged at revision: 87
Proposed branch: lp:~jml/pkgme/pickleable-exceptions
Merge into: lp:pkgme
Diff against target: 46 lines (+8/-8)
1 file modified
pkgme/run_script.py (+8/-8)
To merge this branch: bzr merge lp:~jml/pkgme/pickleable-exceptions
Reviewer Review Type Date Requested Status
pkgme committers Pending
Review via email: mp+83171@code.launchpad.net

Description of the change

Turns out that celery pickles exceptions, and that you need to pass arguments to the parent classes in order to have exceptions pickle and unpickle successfully. Pickling is important for getting full error messages out of the tasks. In particular, the custom logic that we used to show the output from failed pkgme scripts wasn't getting used until I applied this patch.

http://celery.readthedocs.org/en/latest/userguide/tasks.html#creating-pickleable-exceptions

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'pkgme/run_script.py'
--- pkgme/run_script.py 2011-10-31 16:18:41 +0000
+++ pkgme/run_script.py 2011-11-23 14:31:37 +0000
@@ -9,15 +9,15 @@
99
10class ScriptProblem(PkgmeError):10class ScriptProblem(PkgmeError):
1111
12 def __init__(self, script_path):12 def __init__(self, script_path, *args):
13 super(ScriptProblem, self).__init__()13 super(ScriptProblem, self).__init__(script_path, *args)
14 self.script_path = script_path14 self.script_path = script_path
1515
1616
17class ScriptMissing(ScriptProblem):17class ScriptMissing(ScriptProblem):
1818
19 def __init__(self, script_path):19 def __init__(self, script_path, *args):
20 super(ScriptMissing, self).__init__(script_path)20 super(ScriptMissing, self).__init__(script_path, *args)
2121
22 def __str__(self):22 def __str__(self):
23 return "%s not found" % (self.script_path, )23 return "%s not found" % (self.script_path, )
@@ -26,18 +26,18 @@
26class ScriptPermissionDenied(ScriptProblem):26class ScriptPermissionDenied(ScriptProblem):
27 """Attempting to run a script led to a permission denied error."""27 """Attempting to run a script led to a permission denied error."""
2828
29 def __init__(self, script_path):29 def __init__(self, script_path, *args):
30 super(ScriptPermissionDenied, self).__init__(script_path)30 super(ScriptPermissionDenied, self).__init__(script_path, *args)
3131
32 def __str__(self):32 def __str__(self):
33 return ("permission denied trying to execute %s, is it executable?" 33 return ("permission denied trying to execute %s, is it executable?"
34 % (self.script_path, ))34 % (self.script_path, ))
3535
3636
37class ScriptFailed(ScriptProblem):37class ScriptFailed(ScriptProblem):
3838
39 def __init__(self, command, returncode, output_lines):39 def __init__(self, command, returncode, output_lines):
40 super(ScriptFailed, self).__init__(command[0])40 super(ScriptFailed, self).__init__(command, returncode, output_lines)
41 self.command = command41 self.command = command
42 self.returncode = returncode42 self.returncode = returncode
43 self.output_lines = output_lines43 self.output_lines = output_lines

Subscribers

People subscribed via source and target branches