Closed dobesv closed 7 years ago
@dobesv Have you tried to what happens if you initialize the CodeBuilder
in the constructor of Compiler
as object level instance?
I'm evaluating to switch from Mustache to Handlebars, and would need to replace pystache by a Python Handlebars implementation. And pybars3 looks good so far. To run it efficiently in Google App Engine, I would need it to be threadsafe though.
I gave up on pybars3 and used a different template system instead. I haven't regretted it.
On Sat, Mar 18, 2017, 2:22 AM Anastasios Hatzis notifications@github.com wrote:
@dobesv https://github.com/dobesv Have you tried to what happens if you initialize the CodeBuilder in the constructor of Compiler as object level instance?
I'm evaluating to switch from Mustache to Handlebars, and would need to replace pystache by a Python Handlebars implementation. And pybars3 looks good so far. To run it efficiently in Google App Engine, I would need it to be threadsafe though.
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/wbond/pybars3/issues/42#issuecomment-287528876, or mute the thread https://github.com/notifications/unsubscribe-auth/AAUAmTRDBg3CqybTOeMPGLoEPqDwCuSpks5rm6I_gaJpZM4LuAEW .
There is no way to make it thread safe, you would just have to use a global lock when using pybars3.
On Sat, Mar 18, 2017, 9:09 AM Dobes Vandermeer dobesv@gmail.com wrote:
I gave up on pybars3 and used a different template system instead. I haven't regretted it.
On Sat, Mar 18, 2017, 2:22 AM Anastasios Hatzis notifications@github.com wrote:
@dobesv https://github.com/dobesv Have you tried to what happens if you initialize the CodeBuilder in the constructor of Compiler as object level instance?
I'm evaluating to switch from Mustache to Handlebars, and would need to replace pystache by a Python Handlebars implementation. And pybars3 looks good so far. To run it efficiently in Google App Engine, I would need it to be threadsafe though.
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/wbond/pybars3/issues/42#issuecomment-287528876, or mute the thread https://github.com/notifications/unsubscribe-auth/AAUAmTRDBg3CqybTOeMPGLoEPqDwCuSpks5rm6I_gaJpZM4LuAEW .
Sometimes I get errors while compiling a template, but not always. I've also had cases where a template appeared to be corrupted.
Looking at the code I see that every
Compiler
instance shares an instance ofCodeBuilder
because theCodeBuilder
is constructed as a class level field_builder
instead of initializing in the constructor.CodeBuilder
appears to use mutable fields inself
while it compiles the code, so you cannot share an instance ofCodeBuilder
between instances ofCompiler
in parallel.