Commit 81f4aad3 authored by Julian Andres Klode's avatar Julian Andres Klode
Browse files

hashes: Release GIL while hashing stuff

parent f087ac3e
......@@ -45,11 +45,17 @@ static int hashes_init(PyObject *self, PyObject *args, PyObject *kwds)
char *s;
Py_ssize_t len;
PyBytes_AsStringAndSize(object, &s, &len);
Py_BEGIN_ALLOW_THREADS
hashes.Add((const unsigned char*)s, len);
Py_END_ALLOW_THREADS
}
else if ((Fd = PyObject_AsFileDescriptor(object)) != -1) {
struct stat St;
if (fstat(Fd, &St) != 0 || hashes.AddFD(Fd, St.st_size) == false) {
bool err = false;
Py_BEGIN_ALLOW_THREADS
err = fstat(Fd, &St) != 0 || hashes.AddFD(Fd, St.st_size) == false;
Py_END_ALLOW_THREADS
if (err) {
PyErr_SetFromErrno(PyAptError);
return -1;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment