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

[Question] Is the engine meant to be used as a singleton? #788

Closed
smadurange opened this issue Oct 21, 2020 · 3 comments
Closed

[Question] Is the engine meant to be used as a singleton? #788

smadurange opened this issue Oct 21, 2020 · 3 comments

Comments

@smadurange
Copy link

I'm wondering if it's okay to just create instances of the engine as and when I need it or is it meant to be use as a singleton in the application?

@lahma
Copy link
Collaborator

lahma commented Oct 21, 2020

Engine is not thread safe so you shouldn't have it as a singleton in multi-threaded application. It's OK to create multiple instances.

@ayende
Copy link
Contributor

ayende commented Oct 21, 2020

To add to that, while the engine isn't thread safe, is is fine (and expected) that you'll reuse the engine to execute scripts multiple times.
This allows you to save on the initialization costs, especially if you want to have some init scripts / environment to offer.

@lahma
Copy link
Collaborator

lahma commented Oct 22, 2020

You might also want to keep an eye on #789 as there's probably going to be a default implementation for engine pool.

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

No branches or pull requests

3 participants