MCPcopy Create free account
hub / github.com/RedisGears/RedisGears / getCommand

Function getCommand

plugins/python/redisgears_python.c:4625–4653  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4623}
4624
4625static PyObject* getCommand(PyObject *cls, PyObject *args){
4626 PythonThreadCtx* ptctx = GetPythonThreadCtx();
4627
4628 CommandCtx* commandCtx = getCommandCtx(ptctx);
4629 if(!commandCtx){
4630 PyErr_SetString(GearsError, "Can not get command ctx");
4631 return NULL;
4632 }
4633
4634 // we must take the lock, it is not safe to access the command args without the lock because redis might
4635 // change them under our noise
4636 RedisGears_LockHanlderAcquire(staticCtx);
4637
4638 size_t len;
4639 RedisModuleString** argv = RedisGears_CommandCtxGetCommand(commandCtx, &len);
4640
4641 PyObject *list = PyList_New(0);
4642
4643 for(size_t i = 0 ; i < len ; ++i){
4644 size_t strLen;
4645 const char* arg = RedisModule_StringPtrLen(argv[i], &strLen);
4646 PyObject* pyArg = PyUnicode_FromStringAndSize(arg, strLen);
4647 PyList_Append(list, pyArg);
4648 }
4649
4650 RedisGears_LockHanlderRelease(staticCtx);
4651
4652 return list;
4653}
4654
4655static PyObject* callNext(PyObject *cls, PyObject *args){
4656 PythonThreadCtx* ptctx = GetPythonThreadCtx();

Callers

nothing calls this directly

Calls 2

GetPythonThreadCtxFunction · 0.85
getCommandCtxFunction · 0.85

Tested by

no test coverage detected