Skip to content
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

Implement fine-grained control of bg module load delay #8

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

paulie-g
Copy link

@paulie-g paulie-g commented Apr 5, 2019

The background module loader delays before importing the given module. Currently, it does this in one particular way - check len(sys.modules) and proceed only when it stops growing. The parameters it uses to do so are hardcoded.

I have implemented parametrization for this functionality. Caller can now pass in an object with a wait() interface. The existing method is still the default complete with its previously hardcoded parameters, although they can now be changed at call-time. Additional delay implementations have been added:

  • Noop (no wait)
  • Exponential back-off
  • Constant time delay
  • Block on threading.Event
    I've added the comments and unit tests for all of them.

My particular use case involves needing to avoid time.sleep() there (the Noop case), because it triggers a deadlock when running tests under nose. However, I think the others might be useful to others.

To be clear: the default path has not functionally changed and all unit tests pass.

@scopatz
Copy link
Member

scopatz commented May 24, 2019

Thanks so much for putting this in @paulie-g!

@scopatz
Copy link
Member

scopatz commented May 24, 2019

And sorry for taking so long to review this

@scopatz
Copy link
Member

scopatz commented May 24, 2019

This looks great! Could you please add a news entry, as per https://regro.github.io/rever-docs/news.html

Happy to merge this and then do a release!

@paulie-g
Copy link
Author

I'm happy to do that if you like, although I would've thought this would be done by the person doing the release. How would you like to label and formulate the change? Presumably there's a standard for enhancements, 'Added'? How much detail is usually in the news entries?

@scopatz
Copy link
Member

scopatz commented May 30, 2019

I'm happy to do that if you like, although I would've thought this would be done by the person doing the release.

Yeah, we democratize the release process so that it is part of the PR. As you can see in https://regro.github.io/rever-docs/news.html all you need to do to get started is go into the news/ dir and copy the TEMPLATE file over to a new file (usually named after the branch) and then fill in that new file.

Base automatically changed from master to main March 15, 2021 15:11
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.

2 participants