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

Release the GIL in opportune places #103

Merged
merged 1 commit into from
Oct 23, 2023
Merged
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
10 changes: 10 additions & 0 deletions zfec/_fecmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,10 @@ Encoder_init(Encoder *self, PyObject *args, PyObject *kwdict) {
}
self->kk = (unsigned short)ink;
self->mm = (unsigned short)inm;

Py_BEGIN_ALLOW_THREADS
self->fec_matrix = fec_new(self->kk, self->mm);
Py_END_ALLOW_THREADS

return 0;
}
Expand Down Expand Up @@ -207,7 +210,9 @@ Encoder_encode(Encoder *self, PyObject *args) {
assert (check_block_index == num_check_blocks_produced);

/* Encode any check blocks that are needed. */
Py_BEGIN_ALLOW_THREADS
fec_encode(self->fec_matrix, incblocks, check_blocks_produced, c_desired_checkblocks_ids, num_check_blocks_produced, sz);
Py_END_ALLOW_THREADS

/* Wrap all requested blocks up into a Python list of Python strings. */
result = PyList_New(num_desired_blocks);
Expand Down Expand Up @@ -360,7 +365,10 @@ Decoder_init(Encoder *self, PyObject *args, PyObject *kwdict) {
}
self->kk = (unsigned short)ink;
self->mm = (unsigned short)inm;

Py_BEGIN_ALLOW_THREADS
self->fec_matrix = fec_new(self->kk, self->mm);
Py_END_ALLOW_THREADS

return 0;
}
Expand Down Expand Up @@ -478,7 +486,9 @@ Decoder_decode(Decoder *self, PyObject *args) {
}

/* Decode any recovered blocks that are needed. */
Py_BEGIN_ALLOW_THREADS
fec_decode(self->fec_matrix, cblocks, recoveredcstrs, cblocknums, sz);
Py_END_ALLOW_THREADS

/* Wrap up both original primary blocks and decoded blocks into a Python list of Python strings. */
result = PyList_New(self->kk);
Expand Down
Loading