Permalink
Browse files

FIX race in python imports

  • Loading branch information...
spirali committed Jul 26, 2018
1 parent f93d94e commit 0f48f01557e5ec6f17b8d0b4fe61cfe74b964364
Showing with 11 additions and 3 deletions.
  1. +9 −1 python/loom/wside/core.py
  2. +2 −2 src/libloomw/python/core.cpp
@@ -1,6 +1,6 @@
import cloudpickle
import loom_c

import threading

class Context:

@@ -41,3 +41,11 @@ def execute(fn_obj, data, inputs, task_id):
return fn_obj(context, *inputs)
else:
return fn_obj(*inputs)


unpickle_lock = threading.Lock()


def unpickle(data):
with unpickle_lock:
return cloudpickle.loads(data)
@@ -38,12 +38,12 @@ void loom::ensure_py_init() {
PyObject* loom::deserialize_pyobject(const void *mem, size_t size)
{
// Get cloudpickle
PyObject *cloudpickle = PyImport_ImportModule("cloudpickle");
PyObject *cloudpickle = PyImport_ImportModule("loom.wside.core");
if(!cloudpickle) {
return nullptr;
}

PyObject *loads = PyObject_GetAttrString(cloudpickle, "loads");
PyObject *loads = PyObject_GetAttrString(cloudpickle, "unpickle");
Py_DECREF(cloudpickle);

if(!loads) {

0 comments on commit 0f48f01

Please sign in to comment.