Skip to content

Commit

Permalink
[analyzers]: fix log_to_stderr() gil contention deadlocks
Browse files Browse the repository at this point in the history
  • Loading branch information
skystrife committed Aug 16, 2017
1 parent 23bd3c0 commit 234d37f
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/metapy_analyzers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -415,6 +415,7 @@ void metapy_bind_analyzers(py::module& m)
.def("__init__",
[](ngram_pos_analyzer& ana, uint16_t n, const token_stream& ts,
const std::string& crf_prefix) {
py::gil_scoped_release rel;
new (&ana) ngram_pos_analyzer(n, ts.clone(), crf_prefix);
})
.def("analyze", &ngram_analyze<ngram_pos_analyzer, uint64_t>)
Expand Down Expand Up @@ -442,6 +443,7 @@ void metapy_bind_analyzers(py::module& m)
[](tree_analyzer& ana, const token_stream& ts,
const std::string& tagger_prefix,
const std::string& parser_prefix) {
py::gil_scoped_release rel;
new (&ana)
tree_analyzer(ts.clone(), tagger_prefix, parser_prefix);
})
Expand All @@ -452,6 +454,7 @@ void metapy_bind_analyzers(py::module& m)
py::class_<multi_analyzer>{m_ana, "MultiAnalyzer", analyzer_base};

m_ana.def("load", [](const std::string& filename) {
py::gil_scoped_release rel;
auto config = cpptoml::parse_file(filename);
return analyzers::load(*config);
});
Expand Down

0 comments on commit 234d37f

Please sign in to comment.