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