Skip to content

Commit

Permalink
use mako's TemplateLookup rather than custom code
Browse files Browse the repository at this point in the history
Related to race-condition observed w/ python3.11, see:

sqlalchemy/mako#378

This will likely not fully solve race-conditions, as those also occur
between rendering from passed string and from file if called
concurrently.

However, using lookup from mako consistently is closer to how Mako is
intended to be used + there seems to be synchronisation between
lookup-calls at least, which should reduce the frequency of concurrency
issues.
  • Loading branch information
ccwienk committed Jun 27, 2023
1 parent 10dfdb6 commit cd91f4d
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions concourse/steps/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,14 @@
import os

import mako.template

import ci.util

import mako.lookup

steps_dir = os.path.abspath(os.path.dirname(__file__))
template_lookup = mako.lookup.TemplateLookup(directories=(steps_dir,))


def step_template(name):
step_file = ci.util.existing_file(os.path.join(steps_dir, name + '.mako'))

return mako.template.Template(filename=step_file)
return template_lookup.get_template(f'/{name}.mako')


def step_def(name):
Expand Down

0 comments on commit cd91f4d

Please sign in to comment.