diff options
author | fsbs <fsbs@users.noreply.github.com> | 2019-09-20 22:18:29 +0000 |
---|---|---|
committer | fsbs <fsbs@users.noreply.github.com> | 2019-09-21 00:18:29 +0200 |
commit | 1cd4a131b8e28d50ace53cbb439c82e153ebb222 (patch) | |
tree | 2e93437780efc2970ffec19f5a5a92b3dd078888 /src/multi.c | |
parent | b0e3e760fb50608f63aaae9cb288a918b913e942 (diff) | |
download | pycurl-1cd4a131b8e28d50ace53cbb439c82e153ebb222.tar.gz |
Allow threads where callbacks can be invoked
Diffstat (limited to 'src/multi.c')
-rw-r--r-- | src/multi.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/multi.c b/src/multi.c index 3407423..a1cb2b4 100644 --- a/src/multi.c +++ b/src/multi.c @@ -95,7 +95,10 @@ util_multi_close(CurlMultiObject *self) if (self->multi_handle != NULL) { CURLM *multi_handle = self->multi_handle; self->multi_handle = NULL; + /* Allow threads because callbacks can be invoked */ + PYCURL_BEGIN_ALLOW_THREADS curl_multi_cleanup(multi_handle); + PYCURL_END_ALLOW_THREADS } } @@ -625,7 +628,10 @@ do_multi_add_handle(CurlMultiObject *self, PyObject *args) PyDict_SetItem(self->easy_object_dict, (PyObject *) obj, Py_True); assert(obj->multi_stack == NULL); + /* Allow threads because callbacks can be invoked */ + PYCURL_BEGIN_ALLOW_THREADS res = curl_multi_add_handle(self->multi_handle, obj->handle); + PYCURL_END_ALLOW_THREADS if (res != CURLM_OK) { PyDict_DelItem(self->easy_object_dict, (PyObject *) obj); CURLERROR_MSG("curl_multi_add_handle() failed due to internal errors"); @@ -660,7 +666,10 @@ do_multi_remove_handle(CurlMultiObject *self, PyObject *args) PyErr_SetString(ErrorObject, "curl object not on this multi-stack"); return NULL; } + /* Allow threads because callbacks can be invoked */ + PYCURL_BEGIN_ALLOW_THREADS res = curl_multi_remove_handle(self->multi_handle, obj->handle); + PYCURL_END_ALLOW_THREADS if (res == CURLM_OK) { PyDict_DelItem(self->easy_object_dict, (PyObject *) obj); // if PyDict_DelItem fails, remove_handle call will also fail. |