@@ -12,7 +12,7 @@ msgid ""
1212msgstr ""
1313"Project-Id-Version : Python 3.12\n "
1414"Report-Msgid-Bugs-To : \n "
15- "POT-Creation-Date : 2024-09-20 14:57 +0000\n "
15+ "POT-Creation-Date : 2024-09-27 14:50 +0000\n "
1616"PO-Revision-Date : 2024-05-11 00:32+0000\n "
1717"Last-Translator : Rafael Fontenelle <rffontenelle@gmail.com>, 2024\n "
1818"Language-Team : Chinese (China) (https://app.transifex.com/python-doc/teams/5390/zh_CN/)\n "
@@ -1256,6 +1256,11 @@ msgid ""
12561256"Reacquire the global interpreter lock.\n"
12571257"Restore the thread state from the local variable."
12581258msgstr ""
1259+ "将线程状态保存到一个局部变量中。\n"
1260+ "释放全局解释器锁。\n"
1261+ "... 执行某些阻塞式的 I/O 操作 ...\n"
1262+ "重新获取全局解释器锁。\n"
1263+ "从局部变量中恢复线程状态。"
12591264
12601265#: ../../c-api/init.rst:888
12611266msgid "This is so common that a pair of macros exists to simplify it::"
@@ -1267,6 +1272,9 @@ msgid ""
12671272"... Do some blocking I/O operation ...\n"
12681273"Py_END_ALLOW_THREADS"
12691274msgstr ""
1275+ "Py_BEGIN_ALLOW_THREADS\n"
1276+ "... 执行某些阻塞式的 I/O 操作 ...\n"
1277+ "Py_END_ALLOW_THREADS"
12701278
12711279#: ../../c-api/init.rst:898
12721280msgid ""
@@ -1289,6 +1297,11 @@ msgid ""
12891297"... Do some blocking I/O operation ...\n"
12901298"PyEval_RestoreThread(_save);"
12911299msgstr ""
1300+ "PyThreadState *_save;\n"
1301+ "\n"
1302+ "_save = PyEval_SaveThread();\n"
1303+ "... 执行某些阻塞式的 I/O 操作 ...\n"
1304+ "PyEval_RestoreThread(_save);"
12921305
12931306#: ../../c-api/init.rst:914
12941307msgid ""
@@ -1367,6 +1380,15 @@ msgid ""
13671380"/* Release the thread. No Python API allowed beyond this point. */\n"
13681381"PyGILState_Release(gstate);"
13691382msgstr ""
1383+ "PyGILState_STATE gstate;\n"
1384+ "gstate = PyGILState_Ensure();\n"
1385+ "\n"
1386+ "/* 在此执行 Python 动作。 */\n"
1387+ "result = CallSomeFunction();\n"
1388+ "/* 评估结果或处理异常 */\n"
1389+ "\n"
1390+ "/* 释放线程。 在此之后不再允许 Python API。 */\n"
1391+ "PyGILState_Release(gstate);"
13701392
13711393#: ../../c-api/init.rst:965
13721394msgid ""
@@ -2226,6 +2248,16 @@ msgid ""
22262248"};\n"
22272249"PyThreadState *tstate = Py_NewInterpreterFromConfig(&config);"
22282250msgstr ""
2251+ "PyInterpreterConfig config = {\n"
2252+ " .use_main_obmalloc = 0,\n"
2253+ " .allow_fork = 0,\n"
2254+ " .allow_exec = 0,\n"
2255+ " .allow_threads = 1,\n"
2256+ " .allow_daemon_threads = 0,\n"
2257+ " .check_multi_interp_extensions = 1,\n"
2258+ " .gil = PyInterpreterConfig_OWN_GIL,\n"
2259+ "};\n"
2260+ "PyThreadState *tstate = Py_NewInterpreterFromConfig(&config);"
22292261
22302262#: ../../c-api/init.rst:1649
22312263msgid ""
0 commit comments