Skip to content

Speedup static collection during development #455

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 4 commits into from
Closed

Speedup static collection during development #455

wants to merge 4 commits into from

Conversation

snoepkast
Copy link
Contributor

The speedup is achieved by only doing the collection once per request instead of once for every time the template tag is used. For reference see issue #428.

found_files[prefixed_path] = (storage, path)
self.copy_file(path, prefixed_path, storage)
def collect(self, request=None):
if not self.request or not self.request is request: # Prevent execution multiple times per request
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could this be a guard?

if self.request and self.request is request:
    return  # Prevent execution multiple times per request
self.request = request
found_files = OrdereDict()
[...]

@cyberdelia
Copy link
Member

Looks good, thanks a lot :bowtie:
It would be lovely if the tests passed 😐

@snoepkast
Copy link
Contributor Author

I don't get why my change would break this? Do you have any idea?

@cyberdelia
Copy link
Member

@snoepkast My current guess, is that your changes in PipelineMixin have broke PipelineExtension, probably because you changed __init__.

@leonardoo
Copy link
Contributor

@snoepkast the problem is the init like say @cyberdelia, you can convert init get request_var to something like this

@property
    def request_var(self):
        if not self._request_var:
            self._request_var = template.Variable('request')
        return self._request_var

and remove the init call in these methods

class StylesheetNode(PipelineMixin, template.Node):
    def __init__(self, name):
         super(StylesheetNode, self).__init__(name) # this call is the problem
         self.name = name
  class JavascriptNode(PipelineMixin, template.Node):
     def __init__(self, name):
         super(JavascriptNode, self).__init__(name) # this call is the problem
         self.name = name

@snoepkast
Copy link
Contributor Author

Locally the tests run now, but apparently not on Travis.. But it fails on a native python 'open file' which has nothing to do with any of this?

@snoepkast
Copy link
Contributor Author

Ahh now I see the PR fixing that problem (#459), so this code should work then.

@cyberdelia
Copy link
Member

Merged in 840bf27

@cyberdelia cyberdelia closed this Jun 6, 2015
@Remiz
Copy link

Remiz commented Jun 8, 2015

Amazing work! Now everything is loading under a second for me.

Thank you so much for this PR guys!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants