Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Create non-conflicting template module names #2

Open
wants to merge 1 commit into from

1 participant

@melor

The genUniqueModuleName() implementation generated module name
conflicts when rendering many templates in quick succession.
The combination of poor time resolution of str(time.time()) due
to the default string representation and too small value range
for the random part resulted in this.

Added a simple retry in case of conflicts.

Fixes mysterious looking failures that look like this:

File "cheetah_DynamicallyCompiledCheetahTemplate_1336479589_95_84044.py", line 58, in init
TypeError: super() argument 1 must be type, not None

@melor melor Create non-conflicting template module names
The genUniqueModuleName() implementation generated module name
conflicts when rendering many templates in quick succession.
The combination of poor time resolution of str(time.time()) due
to the default string representation and too small value range
for the random part resulted in this.

Added a simple retry in case of conflicts.

Fixes mysterious looking failures that look like this:

  File "cheetah_DynamicallyCompiledCheetahTemplate_1336479589_95_84044.py", line 58, in __init__
  TypeError: super() argument 1 must be type, not None
f26d64c
@melor melor referenced this pull request in YelpArchive/cheetah
Closed

Create non-conflicting template module names #25

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Oct 4, 2012
  1. @melor

    Create non-conflicting template module names

    melor authored
    The genUniqueModuleName() implementation generated module name
    conflicts when rendering many templates in quick succession.
    The combination of poor time resolution of str(time.time()) due
    to the default string representation and too small value range
    for the random part resulted in this.
    
    Added a simple retry in case of conflicts.
    
    Fixes mysterious looking failures that look like this:
    
      File "cheetah_DynamicallyCompiledCheetahTemplate_1336479589_95_84044.py", line 58, in __init__
      TypeError: super() argument 1 must be type, not None
This page is out of date. Refresh to see the latest.
Showing with 2 additions and 3 deletions.
  1. +2 −3 cheetah/Template.py
View
5 cheetah/Template.py
@@ -104,9 +104,8 @@ def hashDict(d):
def _genUniqueModuleName(baseModuleName):
"""The calling code is responsible for concurrency locking.
"""
- if baseModuleName not in sys.modules:
- finalName = baseModuleName
- else:
+ finalName = baseModuleName
+ while finalName in sys.modules:
finalName = ('cheetah_%s_%s_%s'%(baseModuleName,
str(time.time()).replace('.', '_'),
str(randrange(10000, 99999))))
Something went wrong with that request. Please try again.