Repository navigation
Replies: 2 comments
|
Hi @t12g, the CEL Python stack is built in C++, so it should be thread compatible unless we've done something silly in the Python wrappers |
|
Your reading of the Go code is correct. Concurrent Parse calls on one shared parser are safe, as long as the parser is not reconfigured after you start sharing it. The reason is in Each call constructs a fresh per-invocation parser and passes a copy of the options into it. All the mutable work (lexer state, macro expansion, error accumulation, AST building) happens on that fresh instance, so two goroutines never touch the same scratch state. The same applies to the It reads Two things worth keeping in mind in your setup:
So the process-wide |
Uh oh!
There was an error while loading. Please reload this page.
Hi,
This is another thread safe question similar to #878.
We are using CEL in Python. We share a single process-wide cel.NewEnv(), built once (no runtime variable/function/extension registration), to evaluate user-authored filters. We only call compile(..., disable_check=True), which in the wrapper takes the compiler->GetParser().Parse(...) path. We make concurrent calls on GetParser().Parse() from multiple threads on the same Compiler. "Compiler instances should be thread-compatible" is documented on the Compiler, but we couldn’t find thread-safety comments on Parser. Based on the code, it appears that it is safe to have concurrent GetParser().Parse() calls, but want to double-check here in case we read it wrong.
tagging @TristonianJones here since he answered the previous thread-safety question
All reactions