Merge lp:~therve/storm/fix-compile-cache into lp:storm

Proposed by Thomas Herve
Status: Merged
Merged at revision: 409
Proposed branch: lp:~therve/storm/fix-compile-cache
Merge into: lp:storm
Diff against target: 59 lines (+11/-5)
1 file modified
storm/expr.py (+11/-5)
To merge this branch: bzr merge lp:~therve/storm/fix-compile-cache
Reviewer Review Type Date Requested Status
Jamu Kakar (community) Approve
Storm Developers Pending
Review via email: mp+75391@code.launchpad.net

Description of the change

The problem here is that we use the same compile cache for different backends. It's likely to only happen in storm test suite, but I solved it in a generic way anyway using the compiler to identify the cache.

To post a comment you must log in.
Revision history for this message
Jamu Kakar (jkakar) wrote :

Nice one, +1!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'storm/expr.py'
2--- storm/expr.py 2011-09-14 15:27:52 +0000
3+++ storm/expr.py 2011-09-14 17:58:01 +0000
4@@ -801,7 +801,7 @@
5 according to this column.
6 """
7 __slots__ = ("name", "table", "primary", "variable_factory",
8- "compile_cache")
9+ "compile_cache", "compile_id")
10
11 def __init__(self, name=Undef, table=Undef, primary=False,
12 variable_factory=None):
13@@ -810,6 +810,7 @@
14 self.primary = int(primary)
15 self.variable_factory = variable_factory or Variable
16 self.compile_cache = None
17+ self.compile_id = None
18
19 @compile.when(Column)
20 def compile_column(compile, column, state):
21@@ -821,14 +822,16 @@
22 alias = state.aliases.get(column)
23 if alias is not None:
24 return compile(alias.name, state, token=True)
25- if column.compile_cache is None:
26+ if column.compile_id != id(compile):
27 column.compile_cache = compile(column.name, state, token=True)
28+ column.compile_id = id(compile)
29 return column.compile_cache
30 state.push("context", COLUMN_PREFIX)
31 table = compile(column.table, state, token=True)
32 state.pop()
33- if column.compile_cache is None:
34+ if column.compile_id != id(compile):
35 column.compile_cache = compile(column.name, state, token=True)
36+ column.compile_id = id(compile)
37 return "%s.%s" % (table, column.compile_cache)
38
39 @compile_python.when(Column)
40@@ -876,16 +879,19 @@
41
42
43 class Table(FromExpr):
44- __slots__ = ("name", "compile_cache")
45+ __slots__ = ("name", "compile_cache", "compile_id")
46
47 def __init__(self, name):
48 self.name = name
49 self.compile_cache = None
50+ self.compile_id = None
51+
52
53 @compile.when(Table)
54 def compile_table(compile, table, state):
55- if table.compile_cache is None:
56+ if table.compile_id != id(compile):
57 table.compile_cache = compile(table.name, state, token=True)
58+ table.compile_id = id(compile)
59 return table.compile_cache
60
61

Subscribers

People subscribed via source and target branches

to status/vote changes: