Py_UNICODE *what;
Py_ssize_t length;
if (!PyArg_ParseTuple(args, "u#", &what, &length))
- return Py_BuildValue("");
+ Py_RETURN_NONE;
{
- jclass writerClass = (*env)->FindClass(env, WRITER_CLASS);
- jmethodID writeMethod = (*env)->GetMethodID(env, writerClass, "write", "([CII)V");
- jcharArray chars = (*env)->NewCharArray(env, (jsize)length);
-
- (*env)->SetCharArrayRegion(env, chars, 0, length, what);
- (*env)->CallVoidMethod(env, sclWriter, writeMethod, chars, 0, length);
+ PyThreadState *my_ts = PyThreadState_Get();
+ if (my_ts == main_ts) {
+ jclass writerClass = (*env)->FindClass(env, WRITER_CLASS);
+ jmethodID writeMethod = (*env)->GetMethodID(env, writerClass, "write", "([CII)V");
+ jcharArray chars = (*env)->NewCharArray(env, (jsize)length);
+
+ (*env)->SetCharArrayRegion(env, chars, 0, length, what);
+ Py_BEGIN_ALLOW_THREADS
+ (*env)->CallVoidMethod(env, sclWriter, writeMethod, chars, 0, length);
+ Py_END_ALLOW_THREADS
+ } else {
+ //TODO
+ }
}
}
- return Py_BuildValue("");
+ Py_RETURN_NONE;
}
static PyMethodDef sclWriterMethods[] = {