Remove use of the Simplified GIL State API so pylibmc works in sub-interpreters
from commit 74d5f9ac0b9da2643c3f
This commit is contained in:
parent
725134931b
commit
ddd2f011f7
@ -675,15 +675,13 @@ static bool _PylibMC_RunSetCommand(PylibMC_Client* self,
|
|||||||
_PylibMC_SetCommand f, char *fname,
|
_PylibMC_SetCommand f, char *fname,
|
||||||
pylibmc_mset* msets, size_t nkeys,
|
pylibmc_mset* msets, size_t nkeys,
|
||||||
size_t min_compress) {
|
size_t min_compress) {
|
||||||
PyGILState_STATE gstate;
|
|
||||||
memcached_st* mc = self->mc;
|
memcached_st* mc = self->mc;
|
||||||
memcached_return rc = MEMCACHED_SUCCESS;
|
memcached_return rc = MEMCACHED_SUCCESS;
|
||||||
int pos;
|
int pos;
|
||||||
bool error = false;
|
bool error = false;
|
||||||
bool allsuccess = true;
|
bool allsuccess = true;
|
||||||
|
|
||||||
gstate = PyGILState_Ensure();
|
Py_BEGIN_ALLOW_THREADS;
|
||||||
PyGILState_Release(gstate);
|
|
||||||
|
|
||||||
for (pos=0; pos < nkeys && !error; pos++) {
|
for (pos=0; pos < nkeys && !error; pos++) {
|
||||||
pylibmc_mset* mset = &msets[pos];
|
pylibmc_mset* mset = &msets[pos];
|
||||||
@ -697,10 +695,8 @@ static bool _PylibMC_RunSetCommand(PylibMC_Client* self,
|
|||||||
size_t compressed_len = 0;
|
size_t compressed_len = 0;
|
||||||
|
|
||||||
if (min_compress && value_len >= min_compress) {
|
if (min_compress && value_len >= min_compress) {
|
||||||
gstate = PyGILState_Ensure();
|
|
||||||
_PylibMC_Deflate(value, value_len,
|
_PylibMC_Deflate(value, value_len,
|
||||||
&compressed_value, &compressed_len);
|
&compressed_value, &compressed_len);
|
||||||
PyGILState_Release(gstate);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (compressed_value != NULL) {
|
if (compressed_value != NULL) {
|
||||||
@ -749,7 +745,7 @@ static bool _PylibMC_RunSetCommand(PylibMC_Client* self,
|
|||||||
|
|
||||||
} /* end for each mset */
|
} /* end for each mset */
|
||||||
|
|
||||||
gstate = PyGILState_Ensure();
|
Py_END_ALLOW_THREADS;
|
||||||
|
|
||||||
/* We only return the last return value, even for a _multi
|
/* We only return the last return value, even for a _multi
|
||||||
operation, but we do set the success on the mset */
|
operation, but we do set the success on the mset */
|
||||||
|
Reference in New Issue
Block a user