🌐 AI搜索 & 代理 主页
Skip to content
Merged
Changes from all commits
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
13 changes: 6 additions & 7 deletions src/embed_tests/TestPyScope.cs
Original file line number Diff line number Diff line change
Expand Up @@ -338,16 +338,16 @@ public void TestThread()
//add function to the scope
//can be call many times, more efficient than ast
ps.Exec(
"import clr\n" +
"from System.Threading import Thread\n" +
"import threading\n" +
"lock = threading.Lock()\n" +
"def update():\n" +
" global res, th_cnt\n" +
" global res, th_cnt\n" +
" with lock:\n" +
" res += bb + 1\n" +
" Thread.MemoryBarrier()\n" +
" th_cnt += 1\n"
);
}
int th_cnt = 3;
int th_cnt = 100;
for (int i = 0; i < th_cnt; i++)
{
System.Threading.Thread th = new System.Threading.Thread(() =>
Expand All @@ -368,9 +368,8 @@ public void TestThread()
{
cnt = ps.Get<int>("th_cnt");
}
Thread.Sleep(10);
Thread.Yield();
}
Thread.MemoryBarrier();
using (Py.GIL())
{
var result = ps.Get<int>("res");
Expand Down