| 1784 | } |
| 1785 | |
| 1786 | static void* registerCreateStreamArgs(PyObject *kargs, const char* prefix, ExecutionMode mode){ |
| 1787 | size_t batch = 1; |
| 1788 | PyObject* pyBatch = GearsPyDict_GetItemString(kargs, "batch"); |
| 1789 | if(pyBatch){ |
| 1790 | if(PyNumber_Check(pyBatch)){ |
| 1791 | batch = PyNumber_AsSsize_t(pyBatch, NULL); |
| 1792 | }else{ |
| 1793 | PyErr_SetString(GearsError, "batch argument must be a number"); |
| 1794 | return NULL; |
| 1795 | } |
| 1796 | } |
| 1797 | |
| 1798 | size_t durationMS = 0; |
| 1799 | PyObject* pydurationInSec = GearsPyDict_GetItemString(kargs, "duration"); |
| 1800 | if(pydurationInSec){ |
| 1801 | if(PyNumber_Check(pydurationInSec)){ |
| 1802 | durationMS = PyNumber_AsSsize_t(pydurationInSec, NULL); |
| 1803 | }else{ |
| 1804 | PyErr_SetString(GearsError, "duration argument must be a number"); |
| 1805 | return NULL; |
| 1806 | } |
| 1807 | } |
| 1808 | |
| 1809 | OnFailedPolicy onFailedPolicy = OnFailedPolicyContinue; |
| 1810 | PyObject* pyOnFailedPolicy = GearsPyDict_GetItemString(kargs, "onFailedPolicy"); |
| 1811 | if(pyOnFailedPolicy){ |
| 1812 | if(PyUnicode_Check(pyOnFailedPolicy)){ |
| 1813 | const char* onFailedPolicyStr = PyUnicode_AsUTF8AndSize(pyOnFailedPolicy, NULL); |
| 1814 | onFailedPolicy = getOnFailedPolicy(onFailedPolicyStr); |
| 1815 | if(onFailedPolicy == OnFailedPolicyUnknown){ |
| 1816 | PyErr_SetString(GearsError, "onFailedPolicy must be Continue/Abort/Retry"); |
| 1817 | return NULL; |
| 1818 | } |
| 1819 | if(mode == ExecutionModeSync && onFailedPolicy != OnFailedPolicyContinue){ |
| 1820 | PyErr_SetString(GearsError, "ExecutionMode sync can only be combined with OnFailedPolicy Continue"); |
| 1821 | return NULL; |
| 1822 | } |
| 1823 | }else{ |
| 1824 | PyErr_SetString(GearsError, "onFailedPolicy must be a string (Continue/Abort/Retry)"); |
| 1825 | return NULL; |
| 1826 | } |
| 1827 | } |
| 1828 | |
| 1829 | size_t retryInterval = 1; |
| 1830 | PyObject* pyRetryInterval = GearsPyDict_GetItemString(kargs, "onFailedRetryInterval"); |
| 1831 | if(pyRetryInterval){ |
| 1832 | if(PyNumber_Check(pyRetryInterval)){ |
| 1833 | retryInterval = PyNumber_AsSsize_t(pyRetryInterval, NULL); |
| 1834 | }else{ |
| 1835 | PyErr_SetString(GearsError, "retryInterval argument must be a number"); |
| 1836 | return NULL; |
| 1837 | } |
| 1838 | } |
| 1839 | |
| 1840 | bool trimStream = true; |
| 1841 | PyObject* pyTrimStream = GearsPyDict_GetItemString(kargs, "trimStream"); |
| 1842 | if(pyTrimStream){ |
| 1843 | if(PyBool_Check(pyTrimStream)){ |
no test coverage detected