| 3234 | } |
| 3235 | |
| 3236 | static PyObject* executeCommand(PyObject *cls, PyObject *args){ |
| 3237 | if(PyTuple_Size(args) < 1){ |
| 3238 | return PyList_New(0); |
| 3239 | } |
| 3240 | RedisModuleCtx* rctx = RedisModule_GetThreadSafeContext(NULL); |
| 3241 | RedisGears_LockHanlderAcquire(rctx); |
| 3242 | |
| 3243 | PyObject* command = PyTuple_GetItem(args, 0); |
| 3244 | if(!PyUnicode_Check(command)){ |
| 3245 | PyErr_SetString(GearsError, "the given command must be a string"); |
| 3246 | RedisGears_LockHanlderRelease(rctx); |
| 3247 | RedisModule_FreeThreadSafeContext(rctx); |
| 3248 | return NULL; |
| 3249 | } |
| 3250 | const char* commandStr = PyUnicode_AsUTF8AndSize(command, NULL); |
| 3251 | |
| 3252 | RedisModuleString** arguments = createArgs(PyTuple_GetSlice(args, 1, PyTuple_Size(args))); |
| 3253 | |
| 3254 | |
| 3255 | RedisModuleCallReply *reply = RedisModule_Call(rctx, commandStr, "!v", arguments, array_len(arguments)); |
| 3256 | |
| 3257 | PyObject* res = createReply(reply); |
| 3258 | |
| 3259 | array_free_ex(arguments, RedisModule_FreeString(rctx, *(RedisModuleString**)ptr)); |
| 3260 | |
| 3261 | RedisGears_LockHanlderRelease(rctx); |
| 3262 | RedisModule_FreeThreadSafeContext(rctx); |
| 3263 | return res; |
| 3264 | } |
| 3265 | |
| 3266 | // LCOV_EXCL_START |
| 3267 |
nothing calls this directly
no test coverage detected