Skip to content

merge changes to get npython working again on windows #41

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Apr 11, 2014
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
make sure the GIL is released in ThreadTest
  • Loading branch information
tonyroberts committed Apr 11, 2014
commit 2b11631a5cc9c08b0ff3359d041ee5ade1fc605f
54 changes: 31 additions & 23 deletions pythonnet/src/testing/threadtest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,35 +39,43 @@ public class ThreadTest {

public static string CallEchoString(string arg) {
IntPtr gs = PythonEngine.AcquireLock();
if (module == null) {
module = PythonEngine.ModuleFromString("tt", testmod);
try {
if (module == null) {
module = PythonEngine.ModuleFromString("tt", testmod);
}
PyObject func = module.GetAttr("echostring");
PyString parg = new PyString(arg);
PyObject temp = func.Invoke(parg);
string result = (string)temp.AsManagedObject(typeof(String));
func.Dispose();
parg.Dispose();
temp.Dispose();
return result;
}
finally {
PythonEngine.ReleaseLock(gs);
}
PyObject func = module.GetAttr("echostring");
PyString parg = new PyString(arg);
PyObject temp = func.Invoke(parg);
string result = (string)temp.AsManagedObject(typeof(String));
func.Dispose();
parg.Dispose();
temp.Dispose();
PythonEngine.ReleaseLock(gs);
return result;
}

public static string CallEchoString2(string arg) {
IntPtr gs = PythonEngine.AcquireLock();
if (module == null) {
module = PythonEngine.ModuleFromString("tt", testmod);
}
try {
if (module == null) {
module = PythonEngine.ModuleFromString("tt", testmod);
}

PyObject func = module.GetAttr("echostring2");
PyString parg = new PyString(arg);
PyObject temp = func.Invoke(parg);
string result = (string)temp.AsManagedObject(typeof(String));
func.Dispose();
parg.Dispose();
temp.Dispose();
PythonEngine.ReleaseLock(gs);
return result;
PyObject func = module.GetAttr("echostring2");
PyString parg = new PyString(arg);
PyObject temp = func.Invoke(parg);
string result = (string)temp.AsManagedObject(typeof(String));
func.Dispose();
parg.Dispose();
temp.Dispose();
return result;
}
finally {
PythonEngine.ReleaseLock(gs);
}
}


Expand Down