| 2866 | } |
| 2867 | |
| 2868 | static PyObject* gearsFutureCtx(PyObject *cls, PyObject *args){ |
| 2869 | if(PyTuple_Size(args) != 0){ |
| 2870 | PyErr_SetString(GearsError, "Future gets no arguments"); |
| 2871 | return NULL; |
| 2872 | } |
| 2873 | |
| 2874 | PythonThreadCtx* ptctx = GetPythonThreadCtx(); |
| 2875 | if(!ptctx->currEctx){ |
| 2876 | PyErr_SetString(GearsError, "Future object can only be created inside certain execution steps"); |
| 2877 | return NULL; |
| 2878 | } |
| 2879 | |
| 2880 | if(ptctx->pyfutureCreated){ |
| 2881 | PyErr_SetString(GearsError, "Can not create async record twice on the same step"); |
| 2882 | return NULL; |
| 2883 | } |
| 2884 | |
| 2885 | char* err = NULL; |
| 2886 | Record *async = RedisGears_AsyncRecordCreate(ptctx->currEctx, &err); |
| 2887 | if(!async){ |
| 2888 | if(!err){ |
| 2889 | err = RG_STRDUP("Failed creating async record"); |
| 2890 | } |
| 2891 | PyErr_SetString(GearsError, err); |
| 2892 | RG_FREE(err); |
| 2893 | return NULL; |
| 2894 | } |
| 2895 | |
| 2896 | PyFuture* pyfuture = PyObject_New(PyFuture, &PyFutureType); |
| 2897 | pyfuture->asyncRecord = async; |
| 2898 | pyfuture->continueType = 0; |
| 2899 | ptctx->pyfutureCreated = (PyObject*)pyfuture; |
| 2900 | Py_INCREF(ptctx->pyfutureCreated); |
| 2901 | return (PyObject*)pyfuture; |
| 2902 | } |
| 2903 | |
| 2904 | static PyObject* registerGearsThread(PyObject *cls, PyObject *args){ |
| 2905 | RedisGears_LockHanlderRegister(); |
nothing calls this directly
no test coverage detected