Warning: Can't synchronize with repository "(default)" (Unsupported version control system "svn": No module named svn). Look in the Trac log for more information.

Ticket #1451 (closed defect: fixed)

Opened 12 years ago

Last modified 12 years ago

[Patch] TurboCheetah's compiled templates cache not thread safe

Reported by: guest Owned by: anonymous
Priority: normal Milestone:
Component: TurboGears Version: trunk
Severity: major Keywords: cheetah, turbocheetah
Cc: pjenvey@…


TurboCheetah?'s compiled template cache has concurrency issues: one thread may detect the compiled template in the cache and attempt to import it, while another thread is in the middle of deleting the compiled template module and recompiling it

This can result in the following error, obviously more easily reproducable under high load:

File '/home/arash/sandbox/dropbox/dropbox/controllers/web.py', line 224 in index
  return render('welcome', **stuff)
File '/usr/lib/python2.4/site-packages/Pylons-0.9.6rc2dev_r2259-py2.4.egg/pylons/templating.py', line 337 in render
  format=format, namespace=kargs, **cache_args)
File '/usr/lib/python2.4/site-packages/Pylons-0.9.6rc2dev_r2259-py2.4.egg/pylons/templating.py', line 223 in render
  return engine_config['engine'].render(namespace, template=full_path,
File '/usr/lib/python2.4/site-packages/TurboCheetah-0.9.5-py2.4.egg/turbocheetah/cheetahsupport.py', line 101 in render
File '/usr/lib/python2.4/site-packages/TurboCheetah-0.9.5-py2.4.egg/turbocheetah/cheetahsupport.py', line 51 in load_template
  return self.load_template_module(template)
File '/usr/lib/python2.4/site-packages/TurboCheetah-0.9.5-py2.4.egg/turbocheetah/cheetahsupport.py', line 81 in load_template_module
  mod = __import__(classname, dict(), dict(), [basename])
ImportError: No module named welcome

the attached patch introduces a lock around the the cache code


cheetahsupport_locking.diff Download (2.3 KB) - added by guest 12 years ago.

Change History

Changed 12 years ago by guest

comment:1 Changed 12 years ago by guest

you might be able to reduce the scope of the lock somewhat -- I honestly haven't extensively tested/played with this patch, a third party actually tested it and verified the fix for me

comment:2 Changed 12 years ago by chrisz

  • Status changed from new to closed
  • Resolution set to fixed

Implemented in TurboCheetah? 1.0 (and similarly, in TurboKid? 1.0.4).

Note: See TracTickets for help on using tickets.