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

Refactor python progress callback #266

Merged
merged 2 commits into from
Dec 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 1 addition & 6 deletions python/src/addons/CompletionDictionaryCompiler.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,4 @@

cdef void* callback = <void*> args[0]
with nogil:
self.inst.get().Compile(callback_wrapper, callback)


# definition for all compilers
cdef void callback_wrapper(size_t a, size_t b, void* py_callback) with gil:
(<object>py_callback)(a, b)
self.inst.get().Compile(progress_compiler_callback, callback)
2 changes: 1 addition & 1 deletion python/src/addons/FloatVectorDictionaryCompiler.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@

cdef void* callback = <void*> args[0]
with nogil:
self.inst.get().Compile(callback_wrapper, callback)
self.inst.get().Compile(progress_compiler_callback, callback)

2 changes: 1 addition & 1 deletion python/src/addons/IntDictionaryCompiler.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@

cdef void* callback = <void*> args[0]
with nogil:
self.inst.get().Compile(callback_wrapper, callback)
self.inst.get().Compile(progress_compiler_callback, callback)

2 changes: 1 addition & 1 deletion python/src/addons/IntDictionaryCompilerSmallData.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@

cdef void* callback = <void*> args[0]
with nogil:
self.inst.get().Compile(callback_wrapper, callback)
self.inst.get().Compile(progress_compiler_callback, callback)

2 changes: 1 addition & 1 deletion python/src/addons/JsonDictionaryCompiler.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@

cdef void* callback = <void*> args[0]
with nogil:
self.inst.get().Compile(callback_wrapper, callback)
self.inst.get().Compile(progress_compiler_callback, callback)

2 changes: 1 addition & 1 deletion python/src/addons/JsonDictionaryCompilerSmallData.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,5 @@

cdef void* callback = <void*> args[0]
with nogil:
self.inst.get().Compile(callback_wrapper, callback)
self.inst.get().Compile(progress_compiler_callback, callback)

2 changes: 1 addition & 1 deletion python/src/addons/KeyOnlyDictionaryCompiler.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@

cdef void* callback = <void*> args[0]
with nogil:
self.inst.get().Compile(callback_wrapper, callback)
self.inst.get().Compile(progress_compiler_callback, callback)

2 changes: 1 addition & 1 deletion python/src/addons/StringDictionaryCompiler.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@

cdef void* callback = <void*> args[0]
with nogil:
self.inst.get().Compile(callback_wrapper, callback)
self.inst.get().Compile(progress_compiler_callback, callback)

5 changes: 5 additions & 0 deletions python/src/addons/autwrap_workarounds.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,8 @@ def get_interpreter_executable():
executable = executable.encode('utf-8')

return executable


# definition for all compilers
cdef void progress_compiler_callback(size_t a, size_t b, void* py_callback) noexcept with gil:
(<object>py_callback)(a, b)
2 changes: 1 addition & 1 deletion python/src/pxds/match.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ cdef extern from "keyvi/dictionary/match.h" namespace "keyvi::dictionary":
void SetScore(float score)
libcpp_utf8_output_string GetMatchedString()
void SetMatchedString (libcpp_utf8_string matched_string)
PyObject* GetAttributePy(libcpp_utf8_string) nogil except + # wrap-ignore
PyObject* GetAttributePy(libcpp_utf8_string) except + nogil # wrap-ignore
libcpp_utf8_output_string GetValueAsString() except +
libcpp_string GetRawValueAsString() except +
libcpp_string GetMsgPackedValueAsString() except + # wrap-ignore
Expand Down
Loading