Merge lp:~javier.collado/utah/bug1156554 into lp:utah

Proposed by Javier Collado
Status: Merged
Approved by: Javier Collado
Approved revision: 836
Merged at revision: 836
Proposed branch: lp:~javier.collado/utah/bug1156554
Merge into: lp:utah
Diff against target: 40 lines (+13/-4)
2 files modified
debian/changelog (+1/-0)
utah/retry.py (+12/-4)
To merge this branch: bzr merge lp:~javier.collado/utah/bug1156554
Reviewer Review Type Date Requested Status
Max Brustkern (community) Approve
Review via email: mp+153783@code.launchpad.net

Description of the change

This branch workarounds and import error problem by setting a hardcoded default
value when the import error happens, that is, when the config module uses the
url_argument function.

I don't like capturing ImportError exceptions, but this is the best I think I
can do to make it possible to use a function in the config module that requires
a default value from the configuration module itself.

If you have some ideas to improve the situation, please let me know.

To post a comment you must log in.
Revision history for this message
Max Brustkern (nuclearbob) wrote :

On line 23, change ImporError to ImportError and I think we're good. I'd like to try to merge this and get testing started for a new stable version today, so if you don't make this change before EOD, I'll make it when I merge.

review: Approve
lp:~javier.collado/utah/bug1156554 updated
836. By Javier Collado

Fixed typo

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'debian/changelog'
2--- debian/changelog 2013-03-01 14:18:10 +0000
3+++ debian/changelog 2013-03-18 15:34:21 +0000
4@@ -9,6 +9,7 @@
5 * Clarified return code values in server and client
6 (LP: #1025633, LP: #1133227)
7 * Added reboot support (LP: #1086450)
8+ * Fixed circular import when UTAH_CONFIG_FILE is set (LP: #1156554)
9
10 [ Max Brustkern ]
11 * Fixed ProvisionedMachine template support (LP: #1147306)
12
13=== modified file 'utah/retry.py'
14--- utah/retry.py 2013-03-13 16:52:34 +0000
15+++ utah/retry.py 2013-03-18 15:34:21 +0000
16@@ -49,12 +49,20 @@
17 .. seealso:: :func:`utah.timeout.timeout`
18
19 """
20- # The following import is in the function body to avoid a cycle:
21+ logmethod = kw.pop('logmethod', sys.stderr.write)
22+
23+ # The following import might cause an ImportError when url_argument is used
24+ # in the config module. To avoid that, a hardcoded default value is used
25+ # for those cases in which the config module hasn't yet been imported.
26+ # The cycle is as follows:
27 # utah.config -> utah.url -> utah.retry -> utah.config
28- from utah import config
29+ try:
30+ from utah import config
31+ retry_timeout = config.retry_timeout
32+ except ImportError:
33+ retry_timeout = 3
34
35- logmethod = kw.pop('logmethod', sys.stderr.write)
36- retry_timeout = kw.pop('retry_timeout', config.retry_timeout)
37+ retry_timeout = kw.pop('retry_timeout', retry_timeout)
38 retval = False
39 while True:
40 try:

Subscribers

People subscribed via source and target branches