| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -11,7 +11,7 @@ This document follows the conventions laid out in [Keep a CHANGELOG][]. | |||
| 11 | 11 | ||
| 12 | 12 | - Ability to instantiate new .NET arrays using `Array[T](dim1, dim2, ...)` syntax | |
| 13 | 13 | - Python operator method will call C# operator method for supported binary and unary operators ([#1324][p1324]). | |
| 14 | - - Add GetNativeThreadID and Interrupt methods in PythonEngine | ||
| 14 | + - Add GetPythonThreadID and Interrupt methods in PythonEngine | ||
| 15 | 15 | ||
| 16 | 16 | ### Changed | |
| 17 | 17 | - Drop support for Python 2, 3.4, and 3.5 | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -31,12 +31,12 @@ public void Dispose() | |||
| 31 | 31 | public void InterruptTest() | |
| 32 | 32 | { | |
| 33 | 33 | int runSimpleStringReturnValue = int.MinValue; | |
| 34 | - ulong nativeThreadID = ulong.MinValue; | ||
| 34 | + ulong pythonThreadID = ulong.MinValue; | ||
| 35 | 35 | Task.Factory.StartNew(() => | |
| 36 | 36 | { | |
| 37 | 37 | using (Py.GIL()) | |
| 38 | 38 | { | |
| 39 | - nativeThreadID = PythonEngine.GetNativeThreadID(); | ||
| 39 | + pythonThreadID = PythonEngine.GetPythonThreadID(); | ||
| 40 | 40 | runSimpleStringReturnValue = PythonEngine.RunSimpleString(@" | |
| 41 | 41 | import time | |
| 42 | 42 | ||
@@ -47,11 +47,11 @@ import time | |||
| 47 | 47 | ||
| 48 | 48 | Thread.Sleep(200); | |
| 49 | 49 | ||
| 50 | - Assert.AreNotEqual(ulong.MinValue, nativeThreadID); | ||
| 50 | + Assert.AreNotEqual(ulong.MinValue, pythonThreadID); | ||
| 51 | 51 | ||
| 52 | 52 | using (Py.GIL()) | |
| 53 | 53 | { | |
| 54 | - int interruptReturnValue = PythonEngine.Interrupt(nativeThreadID); | ||
| 54 | + int interruptReturnValue = PythonEngine.Interrupt(pythonThreadID); | ||
| 55 | 55 | Assert.AreEqual(1, interruptReturnValue); | |
| 56 | 56 | } | |
| 57 | 57 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -568,28 +568,28 @@ public static void Exec(string code, IntPtr? globals = null, IntPtr? locals = nu | |||
| 568 | 568 | } | |
| 569 | 569 | ||
| 570 | 570 | /// <summary> | |
| 571 | - /// Gets the native thread ID. | ||
| 571 | + /// Gets the Python thread ID. | ||
| 572 | 572 | /// </summary> | |
| 573 | - /// <returns>The native thread ID.</returns> | ||
| 574 | - public static ulong GetNativeThreadID() | ||
| 573 | + /// <returns>The Python thread ID.</returns> | ||
| 574 | + public static ulong GetPythonThreadID() | ||
| 575 | 575 | { | |
| 576 | - dynamic threading = Py.Import("threading"); | ||
| 577 | - return threading.get_ident(); | ||
| 576 | + var threading = Py.Import("threading"); | ||
| 577 | + return threading.InvokeMethod("get_ident"); | ||
| 578 | 578 | } | |
| 579 | 579 | ||
| 580 | 580 | /// <summary> | |
| 581 | 581 | /// Interrupts the execution of a thread. | |
| 582 | 582 | /// </summary> | |
| 583 | - /// <param name="nativeThreadID">The native thread ID.</param> | ||
| 583 | + /// <param name="pythonThreadID">The Python thread ID.</param> | ||
| 584 | 584 | /// <returns>The number of thread states modified; this is normally one, but will be zero if the thread id isn’t found.</returns> | |
| 585 | - public static int Interrupt(ulong nativeThreadID) | ||
| 585 | + public static int Interrupt(ulong pythonThreadID) | ||
| 586 | 586 | { | |
| 587 | 587 | if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) | |
| 588 | 588 | { | |
| 589 | - return Runtime.PyThreadState_SetAsyncExcLLP64((uint)nativeThreadID, Exceptions.KeyboardInterrupt); | ||
| 589 | + return Runtime.PyThreadState_SetAsyncExcLLP64((uint)pythonThreadID, Exceptions.KeyboardInterrupt); | ||
| 590 | 590 | } | |
| 591 | 591 | ||
| 592 | - return Runtime.PyThreadState_SetAsyncExcLP64(nativeThreadID, Exceptions.KeyboardInterrupt); | ||
| 592 | + return Runtime.PyThreadState_SetAsyncExcLP64(pythonThreadID, Exceptions.KeyboardInterrupt); | ||
| 593 | 593 | } | |
| 594 | 594 | ||
| 595 | 595 | /// <summary> | |
| Back | FazBrowse Home | New Git URL |
0 commit comments