-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy paththreads.po
More file actions
624 lines (448 loc) · 71.3 KB
/
Copy paththreads.po
File metadata and controls
624 lines (448 loc) · 71.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
# Persian translations for Python package.
# Copyright (C) 2001 Python Software Foundation
# This file is distributed under the same license as the Python package.
# Automatically generated, 2026.
#
# Translators:
# Sepehr Rasouli <sepehrrasouli06@gmail.com>, 2026
#
msgid ""
msgstr ""
"Project-Id-Version: Python 3.14\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2026-09-16 12:56+0000\n"
"PO-Revision-Date: 2026-07-25 12:59+0330\n"
"Last-Translator: Sepehr Rasouli <sepehrrasouli06@gmail.com>, 2026\n"
"Language-Team: none\n"
"Language: fa\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
msgid "Thread states and the global interpreter lock"
msgstr "وضعیتهای نخ و قفل مفسر سراسری"
msgid "Unless on a :term:`free-threaded build` of :term:`CPython`, the Python interpreter is generally not thread-safe. In order to support multi-threaded Python programs, there's a global lock, called the :term:`global interpreter lock` or :term:`GIL`, that must be held by a thread before accessing Python objects. Without the lock, even the simplest operations could cause problems in a multi-threaded program: for example, when two threads simultaneously increment the reference count of the same object, the reference count could end up being incremented only once instead of twice."
msgstr "مگر در :term:`free-threaded build` از :term:`CPython`، مفسر پایتون بهطور کلی نخایمن نیست. به منظور پشتیبانی از برنامههای چندنخی پایتون، یک قفل سراسری به نام :term:`global interpreter lock` یا :term:`GIL` وجود دارد که باید پیش از دسترسی به اشیای پایتون، توسط یک نخ نگه داشته شود. بدون این قفل، حتی سادهترین عملیاتها میتوانند در یک برنامهی چندنخی مشکل ایجاد کنند: برای مثال، وقتی دو نخ همزمان شمارش ارجاع یک شیء واحد را افزایش میدهند، ممکن است شمارش ارجاع در نهایت به جای دو بار، فقط یک بار افزایش یابد."
msgid "As such, only a thread that holds the GIL may operate on Python objects or invoke Python's C API."
msgstr "از این رو، تنها نخی که قفل مفسر سراسری (GIL) را در اختیار دارد، میتواند روی اشیای پایتون عمل کند یا C API پایتون را فراخوانی کند."
msgid "In order to emulate concurrency, the interpreter regularly tries to switch threads between bytecode instructions (see :func:`sys.setswitchinterval`). This is why locks are also necessary for thread-safety in pure-Python code."
msgstr "برای شبیهسازی همزمانی، مفسر بهطور منظم تلاش میکند نخها را بین دستورالعملهای بایتکد تعویض کند (به :func:`sys.setswitchinterval` مراجعه کنید). به همین دلیل است که قفلها برای نخایمنی در کد پایتون خالص نیز ضروری هستند."
msgid "Additionally, the global interpreter lock is released around blocking I/O operations, such as reading or writing to a file. From the C API, this is done by :ref:`detaching the thread state <detaching-thread-state>`."
msgstr "علاوه بر این، قفل مفسر سراسری در اطراف عملیات ورودی/خروجی (I/O) مسدودکننده، مانند خواندن از یک پرونده یا نوشتن در آن، آزاد میشود. از طریق C API، این کار با :ref:`جدا کردن وضعیت نخ <detaching-thread-state>` انجام میشود."
msgid "The Python interpreter keeps some thread-local information inside a data structure called :c:type:`PyThreadState`, known as a :term:`thread state`. Each thread has a thread-local pointer to a :c:type:`PyThreadState`; a thread state referenced by this pointer is considered to be :term:`attached <attached thread state>`."
msgstr "مفسر پایتون برخی از اطلاعات نخمحلی را درون ساختار دادهای به نام :c:type:`PyThreadState` نگه میدارد که به آن :term:`وضعیت نخ <thread state>` گفته میشود. هر نخ یک اشارهگر نخمحلی به یک :c:type:`PyThreadState` دارد؛ وضعیت نخی که این اشارهگر به آن ارجاع میدهد، :term:`متصل <attached thread state>` در نظر گرفته میشود."
msgid "A thread can only have one :term:`attached thread state` at a time. An attached thread state is typically analogous with holding the GIL, except on free-threaded builds. On builds with the GIL enabled, attaching a thread state will block until the GIL can be acquired. However, even on builds with the GIL disabled, it is still required to have an attached thread state, as the interpreter needs to keep track of which threads may access Python objects."
msgstr "یک نخ در هر لحظه تنها میتواند یک :term:`attached thread state` داشته باشد. وضعیت نخ متصل معمولاً معادل با در اختیار داشتن GIL است، بهجز در ساختهای نخآزاد. در ساختهایی که GIL فعال است، متصل کردن یک وضعیت نخ تا زمانی که بتوان GIL را به دست آورد، مسدود میماند. با این حال، حتی در ساختهایی که GIL غیرفعال است، همچنان داشتن یک وضعیت نخ متصل الزامی است، زیرا مفسر باید پیگیری کند که کدام نخها ممکن است به اشیای پایتون دسترسی داشته باشند."
msgid "Even on the free-threaded build, attaching a thread state may block, as the GIL can be re-enabled or threads might be temporarily suspended (such as during a garbage collection)."
msgstr "حتی در ساخت نخآزاد، پیوست کردن وضعیت نخ ممکن است مسدود شود، زیرا قفل مفسر سراسری میتواند دوباره فعال شود یا نخها ممکن است بهطور موقت معلق شوند (مانند هنگام زبالهروبی)."
msgid "Generally, there will always be an attached thread state when using Python's C API, including during embedding and when implementing methods, so it's uncommon to need to set up a thread state on your own. Only in some specific cases, such as in a :c:macro:`Py_BEGIN_ALLOW_THREADS` block or in a fresh thread, will the thread not have an attached thread state. If uncertain, check if :c:func:`PyThreadState_GetUnchecked` returns ``NULL``."
msgstr "بهطور کلی، هنگام استفاده از API زبان C پایتون، همیشه یک وضعیت نخ متصل وجود خواهد داشت، از جمله در حین تعبیه و هنگام پیادهسازی متدها؛ بنابراین بهندرت پیش میآید که لازم باشد خودتان وضعیت نخ ایجاد کنید. تنها در برخی موارد خاص، مانند داخل بلوک :c:macro:`Py_BEGIN_ALLOW_THREADS` یا در یک نخ تازه، نخ وضعیت نخ متصل نخواهد داشت. اگر مطمئن نیستید، بررسی کنید که آیا :c:func:`PyThreadState_GetUnchecked` مقدار ``NULL`` برمیگرداند یا خیر."
msgid "If it turns out that you do need to create a thread state, call :c:func:`PyThreadState_New` followed by :c:func:`PyThreadState_Swap`, or use the dangerous :c:func:`PyGILState_Ensure` function."
msgstr "اگر معلوم شد که واقعاً به ایجاد وضعیت نخ نیاز دارید، :c:func:`PyThreadState_New` و سپس :c:func:`PyThreadState_Swap` را فراخوانی کنید، یا از تابع خطرناک :c:func:`PyGILState_Ensure` استفاده کنید."
msgid "Detaching the thread state from extension code"
msgstr "جدا کردن وضعیت نخ از کد توسعهای"
msgid "Most extension code manipulating the :term:`thread state` has the following simple structure::"
msgstr "بیشتر کدهای توسعهای که :term:`وضعیت نخ <thread state>` را دستکاری میکنند، ساختار سادهی زیر را دارند::"
msgid ""
"Save the thread state in a local variable.\n"
"... Do some blocking I/O operation ...\n"
"Restore the thread state from the local variable."
msgstr ""
"وضعیت نخ را در یک متغیر محلی ذخیره کنید.\n"
"... یک عملیات ورودی/خروجی مسدودکننده انجام دهید ...\n"
"وضعیت نخ را از متغیر محلی بازیابی کنید."
msgid "This is so common that a pair of macros exists to simplify it::"
msgstr "این چنان رایج است که جفتی از ماکروها برای سادهسازی آن وجود دارد::"
msgid ""
"Py_BEGIN_ALLOW_THREADS\n"
"... Do some blocking I/O operation ...\n"
"Py_END_ALLOW_THREADS"
msgstr ""
"Py_BEGIN_ALLOW_THREADS\n"
"... یک عملیات ورودی/خروجی مسدودکننده انجام دهید ...\n"
"Py_END_ALLOW_THREADS"
msgid "The :c:macro:`Py_BEGIN_ALLOW_THREADS` macro opens a new block and declares a hidden local variable; the :c:macro:`Py_END_ALLOW_THREADS` macro closes the block."
msgstr "ماکروی :c:macro:`Py_BEGIN_ALLOW_THREADS` یک بلوک جدید باز میکند و یک متغیر محلی پنهان اعلان میکند؛ ماکروی :c:macro:`Py_END_ALLOW_THREADS` بلوک را میبندد."
msgid "The block above expands to the following code::"
msgstr "بلوک بالا به کد زیر بسط مییابد::"
msgid ""
"PyThreadState *_save;\n"
"\n"
"_save = PyEval_SaveThread();\n"
"... Do some blocking I/O operation ...\n"
"PyEval_RestoreThread(_save);"
msgstr ""
"PyThreadState *_save;\n"
"\n"
"_save = PyEval_SaveThread();\n"
"... یک عملیات ورودی/خروجی مسدودکننده انجام دهید ...\n"
"PyEval_RestoreThread(_save);"
msgid "Here is how these functions work:"
msgstr "نحوه کار این توابع به این صورت است:"
msgid "The attached thread state implies that the GIL is held for the interpreter. To detach it, :c:func:`PyEval_SaveThread` is called and the result is stored in a local variable."
msgstr "متصل بودن وضعیت نخ نشان میدهد که قفل مفسر سراسری (GIL) برای مفسر نگه داشته شده است. برای جدا کردن آن، :c:func:`PyEval_SaveThread` فراخوانی میشود و نتیجه در یک متغیر محلی ذخیره میشود."
msgid "By detaching the thread state, the GIL is released, which allows other threads to attach to the interpreter and execute while the current thread performs blocking I/O. When the I/O operation is complete, the old thread state is reattached by calling :c:func:`PyEval_RestoreThread`, which will wait until the GIL can be acquired."
msgstr "با جدا کردن وضعیت نخ، قفل مفسر سراسری (GIL) آزاد میشود که به نخهای دیگر اجازه میدهد در حالی که نخ فعلی در حال انجام عملیات ورودی/خروجی مسدودکننده است، به مفسر متصل شده و اجرا شوند. هنگامی که عملیات ورودی/خروجی به پایان رسید، وضعیت نخ قبلی با فراخوانی :c:func:`PyEval_RestoreThread` دوباره متصل میشود؛ این تابع تا زمانی که بتوان قفل مفسر سراسری را به دست آورد، منتظر میماند."
msgid "Performing blocking I/O is the most common use case for detaching the thread state, but it is also useful to call it over long-running native code that doesn't need access to Python objects or Python's C API. For example, the standard :mod:`zlib` and :mod:`hashlib` modules detach the :term:`thread state <attached thread state>` when compressing or hashing data."
msgstr "انجام عملیات ورودی/خروجی مسدودکننده رایجترین مورد استفاده برای جداسازی وضعیت نخ است، اما فراخوانی آن روی کد بومی طولانیمدتی که نیازی به دسترسی به اشیاء پایتون یا C API پایتون ندارد نیز مفید است. برای مثال، ماژولهای استاندارد :mod:`zlib` و :mod:`hashlib` هنگام فشردهسازی یا هش کردن دادهها، :term:`وضعیت نخ <attached thread state>` را جدا میکنند."
msgid "On a :term:`free-threaded build`, the :term:`GIL` is usually out of the question, but **detaching the thread state is still required**, because the interpreter periodically needs to block all threads to get a consistent view of Python objects without the risk of race conditions. For example, CPython currently suspends all threads for a short period of time while running the garbage collector."
msgstr "در یک :term:`ساخت نخآزاد <free-threaded build>`، :term:`قفل مفسر سراسری (GIL) <GIL>` معمولاً منتفی است، اما **جدا کردن وضعیت نخ همچنان الزامی است**، زیرا مفسر بهطور دورهای نیاز دارد همهی نخها را مسدود کند تا نمای سازگار از اشیای پایتون را بدون خطر شرایط رقابتی به دست آورد. برای مثال، سیپایتون در حال حاضر هنگام اجرای زبالهروب، همهی نخها را برای مدت کوتاهی معلق میکند."
msgid "Detaching the thread state can lead to unexpected behavior during interpreter finalization. See :ref:`cautions-regarding-runtime-finalization` for more details."
msgstr "جدا کردن وضعیت نخ میتواند در حین نهاییسازی مفسر به رفتار غیرمنتظره منجر شود. برای جزئیات بیشتر به :ref:`cautions-regarding-runtime-finalization` مراجعه کنید."
msgid "APIs"
msgstr "APIها"
msgid "The following macros are normally used without a trailing semicolon; look for example usage in the Python source distribution."
msgstr "ماکروهای زیر معمولاً بدون نقطهویرگول انتهایی استفاده میشوند؛ نمونههای استفاده را در توزیع کد منبع پایتون جستوجو کنید."
msgid "These macros are still necessary on the :term:`free-threaded build` to prevent deadlocks."
msgstr "این ماکروها در :term:`ساخت نخآزاد <free-threaded build>` همچنان برای جلوگیری از بنبستها ضروری هستند."
msgid "This macro expands to ``{ PyThreadState *_save; _save = PyEval_SaveThread();``. Note that it contains an opening brace; it must be matched with a following :c:macro:`Py_END_ALLOW_THREADS` macro. See above for further discussion of this macro."
msgstr "این ماکرو به ``{ PyThreadState *_save; _save = PyEval_SaveThread();`` بسط مییابد. توجه داشته باشید که این ماکرو یک آکولاد باز در بر دارد و باید با ماکروی :c:macro:`Py_END_ALLOW_THREADS` که پس از آن میآید جفت شود. برای بحث بیشتر دربارهی این ماکرو به بالا مراجعه کنید."
msgid "This macro expands to ``PyEval_RestoreThread(_save); }``. Note that it contains a closing brace; it must be matched with an earlier :c:macro:`Py_BEGIN_ALLOW_THREADS` macro. See above for further discussion of this macro."
msgstr "این ماکرو به ``PyEval_RestoreThread(_save); }`` بسط مییابد. توجه داشته باشید که این ماکرو شامل یک آکولاد بسته است و باید با یک ماکروی :c:macro:`Py_BEGIN_ALLOW_THREADS` پیشین جفت شود. برای بحث بیشتر دربارهی این ماکرو، به بالا مراجعه کنید."
msgid "This macro expands to ``PyEval_RestoreThread(_save);``: it is equivalent to :c:macro:`Py_END_ALLOW_THREADS` without the closing brace."
msgstr "این ماکرو به ``PyEval_RestoreThread(_save);`` بسط مییابد: معادل :c:macro:`Py_END_ALLOW_THREADS` بدون آکولاد پایانی است."
msgid "This macro expands to ``_save = PyEval_SaveThread();``: it is equivalent to :c:macro:`Py_BEGIN_ALLOW_THREADS` without the opening brace and variable declaration."
msgstr "این ماکرو به ``_save = PyEval_SaveThread();`` بسط مییابد: معادل :c:macro:`Py_BEGIN_ALLOW_THREADS` بدون آکولاد باز و اعلان متغیر است."
msgid "Non-Python created threads"
msgstr "نخهای ایجادشده خارج از پایتون"
msgid "When threads are created using the dedicated Python APIs (such as the :mod:`threading` module), a thread state is automatically associated with them, However, when a thread is created from native code (for example, by a third-party library with its own thread management), it doesn't hold an attached thread state."
msgstr "وقتی نخها با استفاده از APIهای اختصاصی پایتون (مانند ماژول :mod:`threading`) ایجاد میشوند، یک وضعیت نخ بهطور خودکار با آنها مرتبط میشود؛ با این حال، وقتی یک نخ از کد بومی ایجاد شود (برای مثال، توسط یک کتابخانه شخص ثالث با مدیریت نخ اختصاصی خودش)، وضعیت نخ متصلشدهای ندارد."
msgid "If you need to call Python code from these threads (often this will be part of a callback API provided by the aforementioned third-party library), you must first register these threads with the interpreter by creating a new thread state and attaching it."
msgstr "اگر لازم باشد کد پایتون را از این نخها فراخوانی کنید (اغلب این کار بخشی از یک API کالبک ارائهشده توسط کتابخانه شخص ثالث مذکور خواهد بود)، باید ابتدا با ایجاد یک وضعیت نخ جدید و پیوست دادن آن، این نخها را در مفسر ثبت کنید."
msgid "The most robust way to do this is through :c:func:`PyThreadState_New` followed by :c:func:`PyThreadState_Swap`."
msgstr "مقاومترین راه انجام این کار، استفاده از :c:func:`PyThreadState_New` و سپس :c:func:`PyThreadState_Swap` است."
msgid "``PyThreadState_New`` requires an argument pointing to the desired interpreter; such a pointer can be acquired via a call to :c:func:`PyInterpreterState_Get` from the code where the thread was created."
msgstr "``PyThreadState_New`` به آرگومانی نیاز دارد که به مفسر موردنظر اشاره کند؛ چنین اشارهگری را میتوان از طریق فراخوانی :c:func:`PyInterpreterState_Get` در کدی که نخ در آن ایجاد شده است، به دست آورد."
msgid "For example::"
msgstr "برای مثال::"
msgid ""
"/* The return value of PyInterpreterState_Get() from the\n"
" function that created this thread. */\n"
"PyInterpreterState *interp = thread_data->interp;\n"
"\n"
"/* Create a new thread state for the interpreter. It does not start out\n"
" attached. */\n"
"PyThreadState *tstate = PyThreadState_New(interp);\n"
"\n"
"/* Attach the thread state, which will acquire the GIL. */\n"
"PyThreadState_Swap(tstate);\n"
"\n"
"/* Perform Python actions here. */\n"
"result = CallSomeFunction();\n"
"/* evaluate result or handle exception */\n"
"\n"
"/* Destroy the thread state. No Python API allowed beyond this point. */\n"
"PyThreadState_Clear(tstate);\n"
"PyThreadState_DeleteCurrent();"
msgstr ""
"/* مقدار بازگشتی PyInterpreterState_Get() از تابعی که\n"
" این نخ را ایجاد کرده است. */\n"
"PyInterpreterState *interp = thread_data->interp;\n"
"\n"
"/* ایجاد یک وضعیت نخ جدید برای مفسر. این وضعیت در ابتدا\n"
" متصل نیست. */\n"
"PyThreadState *tstate = PyThreadState_New(interp);\n"
"\n"
"/* اتصال وضعیت نخ، که قفل مفسر سراسری را به دست خواهد آورد. */\n"
"PyThreadState_Swap(tstate);\n"
"\n"
"/* اینجا کنشهای پایتون را انجام دهید. */\n"
"result = CallSomeFunction();\n"
"/* ارزیابی نتیجه یا مدیریت استثنا */\n"
"\n"
"/* تخریب وضعیت نخ. پس از این نقطه هیچ API پایتونی مجاز نیست. */\n"
"PyThreadState_Clear(tstate);\n"
"PyThreadState_DeleteCurrent();"
msgid "If the interpreter finalized before ``PyThreadState_Swap`` was called, then ``interp`` will be a dangling pointer!"
msgstr "اگر مفسر پیش از فراخوانی ``PyThreadState_Swap`` نهاییسازی شده باشد، آنگاه ``interp`` یک اشارهگر معلق (dangling pointer) خواهد بود!"
msgid "Legacy API"
msgstr "API قدیمی"
msgid "Another common pattern to call Python code from a non-Python thread is to use :c:func:`PyGILState_Ensure` followed by a call to :c:func:`PyGILState_Release`."
msgstr "الگوی رایج دیگر برای فراخوانی کد پایتون از یک نخ غیرپایتونی، استفاده از :c:func:`PyGILState_Ensure` و سپس فراخوانی :c:func:`PyGILState_Release` است."
msgid "These functions do not work well when multiple interpreters exist in the Python process. If no Python interpreter has ever been used in the current thread (which is common for threads created outside Python), ``PyGILState_Ensure`` will create and attach a thread state for the \"main\" interpreter (the first interpreter in the Python process)."
msgstr "این توابع زمانی که چندین مفسر در فرایند پایتون وجود داشته باشند، بهخوبی کار نمیکنند. اگر تاکنون هیچ مفسر پایتونی در نخ فعلی استفاده نشده باشد (که این امر برای نخهایی که خارج از پایتون ایجاد شدهاند رایج است)، ``PyGILState_Ensure`` یک وضعیت نخ برای مفسر «اصلی» (اولین مفسر در فرایند پایتون) ایجاد و پیوست میدهد."
msgid "Additionally, these functions have thread-safety issues during interpreter finalization. Using ``PyGILState_Ensure`` during finalization will likely crash the process."
msgstr "علاوه بر این، این توابع در حین نهاییسازی مفسر دارای مشکلات نخایمنی هستند. استفاده از ``PyGILState_Ensure`` در حین نهاییسازی به احتمال زیاد باعث فروپاشی فرایند میشود."
msgid "Usage of these functions look like such::"
msgstr "استفاده از این توابع به این شکل است::"
msgid ""
"PyGILState_STATE gstate;\n"
"gstate = PyGILState_Ensure();\n"
"\n"
"/* Perform Python actions here. */\n"
"result = CallSomeFunction();\n"
"/* evaluate result or handle exception */\n"
"\n"
"/* Release the thread. No Python API allowed beyond this point. */\n"
"PyGILState_Release(gstate);"
msgstr ""
"PyGILState_STATE gstate;\n"
"gstate = PyGILState_Ensure();\n"
"\n"
"/* Perform Python actions here. */\n"
"result = CallSomeFunction();\n"
"/* evaluate result or handle exception */\n"
"\n"
"/* Release the thread. No Python API allowed beyond this point. */\n"
"PyGILState_Release(gstate);"
msgid "Cautions about fork()"
msgstr "هشدارهایی دربارهی fork()"
msgid "Another important thing to note about threads is their behaviour in the face of the C :c:func:`fork` call. On most systems with :c:func:`fork`, after a process forks only the thread that issued the fork will exist. This has a concrete impact both on how locks must be handled and on all stored state in CPython's runtime."
msgstr "نکتهی مهم دیگری که دربارهی نخها باید به آن توجه کرد، رفتار آنها در برابر فراخوانی C :c:func:`fork` است. در بیشتر سیستمهایی که :c:func:`fork` را دارند، پس از انشعاب یک فرایند، تنها نخی که انشعاب را انجام داده است، وجود خواهد داشت. این موضوع هم بر نحوهی مدیریت قفلها و هم بر تمام وضعیت ذخیرهشده در رانتایم سیپایتون تأثیر ملموسی دارد."
msgid "The fact that only the \"current\" thread remains means any locks held by other threads will never be released. Python solves this for :func:`os.fork` by acquiring the locks it uses internally before the fork, and releasing them afterwards. In addition, it resets any :ref:`lock-objects` in the child. When extending or embedding Python, there is no way to inform Python of additional (non-Python) locks that need to be acquired before or reset after a fork. OS facilities such as :c:func:`!pthread_atfork` would need to be used to accomplish the same thing. Additionally, when extending or embedding Python, calling :c:func:`fork` directly rather than through :func:`os.fork` (and returning to or calling into Python) may result in a deadlock by one of Python's internal locks being held by a thread that is defunct after the fork. :c:func:`PyOS_AfterFork_Child` tries to reset the necessary locks, but is not always able to."
msgstr "این واقعیت که فقط نخ «فعلی» باقی میماند، به این معناست که هر قفلی که توسط نخهای دیگر نگهداشته شده است، هرگز آزاد نخواهد شد. پایتون این مشکل را برای :func:`os.fork` با گرفتن قفلهای داخلی خود پیش از انشعاب و آزاد کردن آنها پس از آن حل میکند. علاوه بر این، پایتون هر :ref:`lock-objects` را در فرزند بازنشانی میکند. هنگام توسعه یا تعبیه پایتون، هیچ راهی برای اطلاع دادن به پایتون دربارهی قفلهای اضافی (غیرپایتونی) که باید پیش از انشعاب گرفته شوند یا پس از آن بازنشانی شوند، وجود ندارد. برای انجام همین کار، لازم است از امکانات سیستمعامل مانند :c:func:`!pthread_atfork` استفاده شود. افزون بر این، هنگام توسعه یا تعبیه پایتون، فراخوانی مستقیم :c:func:`fork` بهجای فراخوانی آن از طریق :func:`os.fork` (و بازگشت به پایتون یا فراخوانی کدهای پایتون) ممکن است به بنبست منجر شود؛ زیرا یکی از قفلهای داخلی پایتون توسط نخی نگهداشته میشود که پس از انشعاب از کار افتاده است. :c:func:`PyOS_AfterFork_Child` میکوشد قفلهای لازم را بازنشانی کند، اما همیشه قادر به انجام آن نیست."
msgid "The fact that all other threads go away also means that CPython's runtime state there must be cleaned up properly, which :func:`os.fork` does. This means finalizing all other :c:type:`PyThreadState` objects belonging to the current interpreter and all other :c:type:`PyInterpreterState` objects. Due to this and the special nature of the :ref:`\"main\" interpreter <sub-interpreter-support>`, :c:func:`fork` should only be called in that interpreter's \"main\" thread, where the CPython global runtime was originally initialized. The only exception is if :c:func:`exec` will be called immediately after."
msgstr "این واقعیت که همه نخهای دیگر از بین میروند، همچنین به این معناست که وضعیت رانتایم سیپایتون در آنجا باید بهدرستی پاکسازی شود، که :func:`os.fork` این کار را انجام میدهد. این به معنای نهایی کردن همه اشیاء دیگر :c:type:`PyThreadState` متعلق به مفسر فعلی و همه اشیاء دیگر :c:type:`PyInterpreterState` است. به دلیل این موضوع و ماهیت خاص :ref:`مفسر «اصلی» <sub-interpreter-support>`، :c:func:`fork` باید فقط در نخ «اصلی» آن مفسر فراخوانی شود، جایی که رانتایم سراسری سیپایتون در ابتدا راهاندازی شده بود. تنها استثنا زمانی است که :c:func:`exec` بلافاصله پس از آن فراخوانی شود."
msgid "High-level APIs"
msgstr "APIهای سطحبالا"
msgid "These are the most commonly used types and functions when writing multi-threaded C extensions."
msgstr "اینها پرکاربردترین نوعها و توابع هنگام نوشتن توسعههای C چندنخی هستند."
msgid "This data structure represents the state of a single thread. The only public data member is:"
msgstr "این ساختار داده، وضعیت یک نخ منفرد را نشان میدهد. تنها عضو دادهی عمومی عبارت است از:"
msgid "This thread's interpreter state."
msgstr "وضعیت مفسر این نخ."
msgid "Deprecated function which does nothing."
msgstr "تابع منسوخ که هیچ کاری انجام نمیدهد."
msgid "In Python 3.6 and older, this function created the GIL if it didn't exist."
msgstr "در پایتون 3.6 و نسخههای قدیمیتر، این تابع در صورت عدم وجود، قفل مفسر سراسری را ایجاد میکرد."
msgid "The function now does nothing."
msgstr "تابع اکنون هیچ کاری انجام نمیدهد."
msgid "This function is now called by :c:func:`Py_Initialize()`, so you don't have to call it yourself anymore."
msgstr "این تابع اکنون توسط :c:func:`Py_Initialize()` فراخوانی میشود، بنابراین دیگر لازم نیست خودتان آن را فراخوانی کنید."
msgid "This function cannot be called before :c:func:`Py_Initialize()` anymore."
msgstr "این تابع دیگر نمیتواند پیش از :c:func:`Py_Initialize()` فراخوانی شود."
msgid "Detach the :term:`attached thread state` and return it. The thread will have no :term:`thread state` upon returning."
msgstr ":term:`attached thread state` را جدا کنید و آن را برگردانید. پس از بازگشت، نخ هیچ :term:`thread state` نخواهد داشت."
msgid "Set the :term:`attached thread state` to *tstate*. The passed :term:`thread state` **should not** be :term:`attached <attached thread state>`, otherwise deadlock ensues. *tstate* will be attached upon returning."
msgstr ":term:`وضعیت نخ متصل <attached thread state>` را به *tstate* تنظیم کنید. :term:`وضعیت نخ <thread state>` ارسالشده **نباید** :term:`متصل <attached thread state>` باشد، در غیر این صورت بنبست رخ میدهد. پس از بازگشت، *tstate* متصل خواهد شد."
msgid "Calling this function from a thread when the runtime is finalizing will hang the thread until the program exits, even if the thread was not created by Python. Refer to :ref:`cautions-regarding-runtime-finalization` for more details."
msgstr "فراخوانی این تابع از یک نخ در زمانی که رانتایم در حال نهاییسازی است، باعث میشود نخ تا زمان خروج از برنامه معلق بماند، حتی اگر آن نخ توسط پایتون ایجاد نشده باشد. برای جزئیات بیشتر به :ref:`cautions-regarding-runtime-finalization` مراجعه کنید."
msgid "Hangs the current thread, rather than terminating it, if called while the interpreter is finalizing."
msgstr "اگر در حین نهاییسازی مفسر فراخوانی شود، نخ فعلی را معلق میکند، نه اینکه آن را خاتمه دهد."
msgid "Return the :term:`attached thread state`. If the thread has no attached thread state, (such as when inside of :c:macro:`Py_BEGIN_ALLOW_THREADS` block), then this issues a fatal error (so that the caller needn't check for ``NULL``)."
msgstr ":term:`attached thread state` را برمیگرداند. اگر نخ وضعیت نخ متصلی نداشته باشد (مانند زمانی که درون بلوک :c:macro:`Py_BEGIN_ALLOW_THREADS` هستیم)، خطای مهلک ایجاد میشود (تا فراخواننده نیازی به بررسی ``NULL`` نداشته باشد)."
msgid "See also :c:func:`PyThreadState_GetUnchecked`."
msgstr "همچنین :c:func:`PyThreadState_GetUnchecked` را ببینید."
msgid "Similar to :c:func:`PyThreadState_Get`, but don't kill the process with a fatal error if it is NULL. The caller is responsible to check if the result is NULL."
msgstr "مشابه :c:func:`PyThreadState_Get`، اما اگر NULL باشد، فرایند را با خطای مهلک از بین نمیبرد. فراخواننده مسئول بررسی NULL بودن نتیجه است."
msgid "In Python 3.5 to 3.12, the function was private and known as ``_PyThreadState_UncheckedGet()``."
msgstr "در پایتون 3.5 تا 3.12، این تابع خصوصی بود و به نام ``_PyThreadState_UncheckedGet()`` شناخته میشد."
msgid "Set the :term:`attached thread state` to *tstate*, and return the :term:`thread state` that was attached prior to calling."
msgstr ":term:`attached thread state` را روی *tstate* تنظیم میکند و :term:`thread state` را که پیش از فراخوانی متصل بوده است، بازمیگرداند."
msgid "This function is safe to call without an :term:`attached thread state`; it will simply return ``NULL`` indicating that there was no prior thread state."
msgstr "فراخوانی این تابع بدون :term:`وضعیت نخ متصل <attached thread state>` ایمن است؛ این تابع صرفاً ``NULL`` را برمیگرداند که نشان میدهد هیچ وضعیت نخ پیشینی وجود نداشته است."
msgid ":c:func:`PyEval_ReleaseThread`"
msgstr ":c:func:`PyEval_ReleaseThread`"
msgid "Similar to :c:func:`PyGILState_Ensure`, this function will hang the thread if the runtime is finalizing."
msgstr "مشابه :c:func:`PyGILState_Ensure`، این تابع در صورتی که رانتایم در حال نهاییسازی باشد، نخ را معلق میکند."
msgid "GIL-state APIs"
msgstr "APIهای وضعیت قفل مفسر سراسری"
msgid "The following functions use thread-local storage, and are not compatible with sub-interpreters:"
msgstr "توابع زیر از ذخیرهسازی نخمحلی استفاده میکنند و با زیرمفسرها (sub-interpreters) سازگار نیستند:"
msgid "The type of the value returned by :c:func:`PyGILState_Ensure` and passed to :c:func:`PyGILState_Release`."
msgstr "نوع مقداری که توسط :c:func:`PyGILState_Ensure` بازگردانده میشود و به :c:func:`PyGILState_Release` پاس داده میشود."
msgid "The GIL was already held when :c:func:`PyGILState_Ensure` was called."
msgstr "هنگام فراخوانی :c:func:`PyGILState_Ensure`، قفل مفسر سراسری از قبل گرفته شده بود."
msgid "The GIL was not held when :c:func:`PyGILState_Ensure` was called."
msgstr "قفل مفسر سراسری هنگام فراخوانی :c:func:`PyGILState_Ensure` در اختیار گرفته نشده بود."
msgid "Ensure that the current thread is ready to call the Python C API regardless of the current state of Python, or of the :term:`attached thread state`. This may be called as many times as desired by a thread as long as each call is matched with a call to :c:func:`PyGILState_Release`. In general, other thread-related APIs may be used between :c:func:`PyGILState_Ensure` and :c:func:`PyGILState_Release` calls as long as the thread state is restored to its previous state before the Release(). For example, normal usage of the :c:macro:`Py_BEGIN_ALLOW_THREADS` and :c:macro:`Py_END_ALLOW_THREADS` macros is acceptable."
msgstr "تضمین میکند که نخ فعلی، صرفنظر از وضعیت فعلی پایتون یا :term:`وضعیت نخ متصل <attached thread state>`، برای فراخوانی Python C API آماده باشد. یک نخ میتواند این تابع را به هر تعداد که مطلوب است فراخوانی کند، به شرط آنکه هر فراخوانی با یک فراخوانی :c:func:`PyGILState_Release` جفت شود. بهطور کلی، میتوان بین فراخوانیهای :c:func:`PyGILState_Ensure` و :c:func:`PyGILState_Release` از سایر APIهای مربوط به نخ استفاده کرد، به شرط آنکه وضعیت نخ پیش از Release() به وضعیت پیشین خود بازگردانی شود. برای نمونه، استفادهی معمول از ماکروهای :c:macro:`Py_BEGIN_ALLOW_THREADS` و :c:macro:`Py_END_ALLOW_THREADS` قابلقبول است."
msgid "The return value is an opaque \"handle\" to the :term:`attached thread state` when :c:func:`PyGILState_Ensure` was called, and must be passed to :c:func:`PyGILState_Release` to ensure Python is left in the same state. Even though recursive calls are allowed, these handles *cannot* be shared - each unique call to :c:func:`PyGILState_Ensure` must save the handle for its call to :c:func:`PyGILState_Release`."
msgstr "مقدار بازگشتی، یک «دسته» مات برای :term:`attached thread state` در زمان فراخوانی :c:func:`PyGILState_Ensure` است و باید به :c:func:`PyGILState_Release` پاس داده شود تا اطمینان حاصل شود که پایتون در همان وضعیت باقی میماند. هرچند فراخوانیهای بازگشتی مجاز هستند، این دستهها *نمیتوانند* به اشتراک گذاشته شوند؛ هر فراخوانی مجزای :c:func:`PyGILState_Ensure` باید دسته را برای فراخوانی خود به :c:func:`PyGILState_Release` ذخیره کند."
msgid "When the function returns, there will be an :term:`attached thread state` and the thread will be able to call arbitrary Python code. Failure is a fatal error."
msgstr "هنگامی که تابع بازمیگردد، یک :term:`attached thread state` وجود خواهد داشت و نخ قادر خواهد بود کد دلخواه پایتون را فراخوانی کند. شکست یک خطای مهلک است."
msgid "Calling this function when the runtime is finalizing is unsafe. Doing so will either hang the thread until the program ends, or fully crash the interpreter in rare cases. Refer to :ref:`cautions-regarding-runtime-finalization` for more details."
msgstr "فراخوانی این تابع هنگامی که رانتایم در حال نهاییسازی است، ناامن است. انجام این کار یا باعث میشود نخ تا پایان برنامه معلق بماند، یا در موارد نادر مفسر بهطور کامل فروپاشی میکند. برای جزئیات بیشتر به :ref:`cautions-regarding-runtime-finalization` مراجعه کنید."
msgid "Release any resources previously acquired. After this call, Python's state will be the same as it was prior to the corresponding :c:func:`PyGILState_Ensure` call (but generally this state will be unknown to the caller, hence the use of the GILState API)."
msgstr "هر منبعی که پیشتر بهدست آمده است را آزاد میکند. پس از این فراخوانی، وضعیت پایتون همان وضعیتی خواهد بود که پیش از فراخوانی متناظر :c:func:`PyGILState_Ensure` وجود داشت (اما بهطور کلی این وضعیت برای فراخواننده ناشناخته است، از این رو از GILState API استفاده میشود)."
msgid "Every call to :c:func:`PyGILState_Ensure` must be matched by a call to :c:func:`PyGILState_Release` on the same thread."
msgstr "هر فراخوانی :c:func:`PyGILState_Ensure` باید با یک فراخوانی :c:func:`PyGILState_Release` روی همان نخ متناظر باشد."
msgid "Get the :term:`attached thread state` for this thread. May return ``NULL`` if no GILState API has been used on the current thread. Note that the main thread always has such a thread-state, even if no auto-thread-state call has been made on the main thread. This is mainly a helper/diagnostic function."
msgstr ":term:`وضعیت نخ متصل <attached thread state>` مربوط به این نخ را برمیگرداند. اگر هیچ APIی GILState روی نخ فعلی استفاده نشده باشد، ممکن است ``NULL`` را برگرداند. توجه داشته باشید که نخ اصلی همیشه چنین وضعیت نخی دارد، حتی اگر هیچ فراخوانی auto-thread-state روی نخ اصلی انجام نشده باشد. این عمدتاً یک تابع کمکی/تشخیصی است."
msgid "This function may return non-``NULL`` even when the :term:`thread state` is detached. Prefer :c:func:`PyThreadState_Get` or :c:func:`PyThreadState_GetUnchecked` for most cases."
msgstr "این تابع ممکن است حتی زمانی که :term:`thread state` جدا شده باشد، مقدار غیر ``NULL`` را برگرداند. برای بیشتر موارد، :c:func:`PyThreadState_Get` یا :c:func:`PyThreadState_GetUnchecked` را ترجیح دهید."
msgid ":c:func:`PyThreadState_Get`"
msgstr ":c:func:`PyThreadState_Get`"
msgid "Return ``1`` if the current thread is holding the :term:`GIL` and ``0`` otherwise. This function can be called from any thread at any time. Only if it has had its :term:`thread state <attached thread state>` initialized via :c:func:`PyGILState_Ensure` will it return ``1``. This is mainly a helper/diagnostic function. It can be useful for example in callback contexts or memory allocation functions when knowing that the :term:`GIL` is locked can allow the caller to perform sensitive actions or otherwise behave differently."
msgstr "اگر نخ فعلی :term:`قفل مفسر سراسری <GIL>` را در اختیار داشته باشد، ``1`` و در غیر این صورت ``0`` را برمیگرداند. این تابع را میتوان در هر زمان از هر نخی فراخوانی کرد. تنها در صورتی ``1`` برمیگرداند که :term:`وضعیت نخ <attached thread state>` آن از طریق :c:func:`PyGILState_Ensure` مقداردهی اولیه شده باشد. این عمدتاً یک تابع کمکی/تشخیصی است. این تابع میتواند برای مثال در زمینههای کالبک یا توابع تخصیص حافظه مفید باشد؛ زمانی که دانستن اینکه :term:`قفل مفسر سراسری <GIL>` گرفته شده است میتواند به فراخوانکننده اجازه دهد تا کنشهای حساسی انجام دهد یا رفتار متفاوتی داشته باشد."
msgid "If the current Python process has ever created a subinterpreter, this function will *always* return ``1``. Prefer :c:func:`PyThreadState_GetUnchecked` for most cases."
msgstr "اگر فرایند فعلی پایتون تا به حال یک زیرمفسر ایجاد کرده باشد، این تابع *همیشه* ``1`` را برمیگرداند. در بیشتر موارد، :c:func:`PyThreadState_GetUnchecked` را ترجیح دهید."
msgid "Low-level APIs"
msgstr "APIهای سطح پایین"
msgid "Create a new thread state object belonging to the given interpreter object. An :term:`attached thread state` is not needed."
msgstr "یک شیء وضعیت نخ جدید متعلق به شیء مفسر دادهشده ایجاد کنید. به یک :term:`وضعیت نخ متصل <attached thread state>` نیازی نیست."
msgid "Reset all information in a :term:`thread state` object. *tstate* must be :term:`attached <attached thread state>`"
msgstr "تمام اطلاعات در یک شیء :term:`وضعیت نخ <thread state>` را بازنشانی میکند. *tstate* باید :term:`متصل <attached thread state>` باشد"
msgid "This function now calls the :c:member:`!PyThreadState.on_delete` callback. Previously, that happened in :c:func:`PyThreadState_Delete`."
msgstr "این تابع اکنون کالبک :c:member:`!PyThreadState.on_delete` را فراخوانی میکند. پیشتر، این کار در :c:func:`PyThreadState_Delete` انجام میشد."
msgid "The :c:member:`!PyThreadState.on_delete` callback was removed."
msgstr "کالبک :c:member:`!PyThreadState.on_delete` حذف شد."
msgid "Destroy a :term:`thread state` object. *tstate* should not be :term:`attached <attached thread state>` to any thread. *tstate* must have been reset with a previous call to :c:func:`PyThreadState_Clear`."
msgstr "یک شیء :term:`وضعیت نخ <thread state>` را نابود میکند. *tstate* نباید به هیچ نخی :term:`متصل <attached thread state>` باشد. *tstate* باید پیشتر با فراخوانی :c:func:`PyThreadState_Clear` بازنشانی شده باشد."
msgid "Detach the :term:`attached thread state` (which must have been reset with a previous call to :c:func:`PyThreadState_Clear`) and then destroy it."
msgstr ":term:`وضعیت نخ متصل <attached thread state>` را جدا کنید (که باید پیشتر با یک فراخوانی از :c:func:`PyThreadState_Clear` بازنشانی شده باشد) و سپس آن را نابود کنید."
msgid "No :term:`thread state` will be :term:`attached <attached thread state>` upon returning."
msgstr "پس از بازگشت، هیچ :term:`thread state`\\ ای :term:`پیوست <attached thread state>` نخواهد شد."
msgid "Get the current frame of the Python thread state *tstate*."
msgstr "گرفتن فریم فعلی وضعیت نخ پایتون *tstate*."
msgid "Return a :term:`strong reference`. Return ``NULL`` if no frame is currently executing."
msgstr "یک :term:`ارجاع قوی <strong reference>` را برمیگرداند. اگر هیچ فریمی هماکنون در حال اجرا نباشد، ``NULL`` را برمیگرداند."
msgid "See also :c:func:`PyEval_GetFrame`."
msgstr "همچنین ببینید :c:func:`PyEval_GetFrame`."
msgid "*tstate* must not be ``NULL``, and must be :term:`attached <attached thread state>`."
msgstr "*tstate* نباید ``NULL`` باشد، و باید :term:`متصل <attached thread state>` باشد."
msgid "Get the unique :term:`thread state` identifier of the Python thread state *tstate*."
msgstr "شناسهی یکتای :term:`thread state` را از وضعیت نخ پایتون *tstate* دریافت کنید."
msgid "Get the interpreter of the Python thread state *tstate*."
msgstr "مفسر وضعیت نخ پایتون *tstate* را برمیگرداند."
msgid "Suspend tracing and profiling in the Python thread state *tstate*."
msgstr "ردگیری و پروفایلگیری را در وضعیت نخ پایتون *tstate* تعلیق میکند."
msgid "Resume them using the :c:func:`PyThreadState_LeaveTracing` function."
msgstr "برای از سر گرفتن آنها، از تابع :c:func:`PyThreadState_LeaveTracing` استفاده کنید."
msgid "Resume tracing and profiling in the Python thread state *tstate* suspended by the :c:func:`PyThreadState_EnterTracing` function."
msgstr "ردگیری و پروفایلگیری را در وضعیت نخ پایتون *tstate* که توسط تابع :c:func:`PyThreadState_EnterTracing` معلق شده است، از سر میگیرد."
msgid "See also :c:func:`PyEval_SetTrace` and :c:func:`PyEval_SetProfile` functions."
msgstr "همچنین توابع :c:func:`PyEval_SetTrace` و :c:func:`PyEval_SetProfile` را ببینید."
msgid "Set the stack protection start address and stack protection size of a Python thread state."
msgstr "آدرس شروع حفاظت پشته و اندازه حفاظت پشتهی یک وضعیت نخ پایتون را تنظیم میکند."
msgid "On success, return ``0``. On failure, set an exception and return ``-1``."
msgstr "در صورت موفقیت، ``0`` برمیگرداند. در صورت شکست، یک استثنا تنظیم کرده و ``-1`` برمیگرداند."
msgid "CPython implements :ref:`recursion control <recursion>` for C code by raising :py:exc:`RecursionError` when it notices that the machine execution stack is close to overflow. See for example the :c:func:`Py_EnterRecursiveCall` function. For this, it needs to know the location of the current thread's stack, which it normally gets from the operating system. When the stack is changed, for example using context switching techniques like the Boost library's ``boost::context``, you must call :c:func:`~PyUnstable_ThreadState_SetStackProtection` to inform CPython of the change."
msgstr "سیپایتون :ref:`کنترل بازگشت <recursion>` را برای کد C به این صورت پیادهسازی میکند که وقتی متوجه میشود که پشته اجرای ماشین نزدیک به سرریز است، :py:exc:`RecursionError` ایجاد میکند. برای نمونه، تابع :c:func:`Py_EnterRecursiveCall` را ببینید. برای این کار، سیپایتون باید مکان پشته نخ فعلی را بداند که معمولاً آن را از سیستمعامل دریافت میکند. هنگامی که پشته تغییر میکند، مثلاً با استفاده از تکنیکهای تعویض زمینه مانند ``boost::context`` در کتابخانه Boost، باید :c:func:`~PyUnstable_ThreadState_SetStackProtection` را فراخوانی کنید تا سیپایتون را از این تغییر مطلع کنید."
msgid "Call :c:func:`~PyUnstable_ThreadState_SetStackProtection` either before or after changing the stack. Do not call any other Python C API between the call and the stack change."
msgstr "تابع :c:func:`~PyUnstable_ThreadState_SetStackProtection` را یا پیش از تغییر پشته یا پس از آن فراخوانی کنید. بین این فراخوانی و تغییر پشته، هیچ فراخوانی دیگری به C API پایتون انجام ندهید."
msgid "See :c:func:`PyUnstable_ThreadState_ResetStackProtection` for undoing this operation."
msgstr "برای بازگردانی این عملیات، به :c:func:`PyUnstable_ThreadState_ResetStackProtection` مراجعه کنید."
msgid "Reset the stack protection start address and stack protection size of a Python thread state to the operating system defaults."
msgstr "نشانی شروع حفاظت پشته و اندازه حفاظت پشته وضعیت نخ پایتون را به پیشفرضهای سیستمعامل بازنشانی میکند."
msgid "See :c:func:`PyUnstable_ThreadState_SetStackProtection` for an explanation."
msgstr "برای توضیح به :c:func:`PyUnstable_ThreadState_SetStackProtection` مراجعه کنید."
msgid "Return a dictionary in which extensions can store thread-specific state information. Each extension should use a unique key to use to store state in the dictionary. It is okay to call this function when no :term:`thread state` is :term:`attached <attached thread state>`. If this function returns ``NULL``, no exception has been raised and the caller should assume no thread state is attached."
msgstr "یک دیکشنری برمیگرداند که افزونهها میتوانند اطلاعات وضعیت مخصوص نخ را در آن ذخیره کنند. هر افزونه باید برای ذخیرهسازی وضعیت در دیکشنری، از یک کلید یکتا استفاده کند. اشکالی ندارد این تابع را زمانی که هیچ :term:`thread state` :term:`متصل <attached thread state>` نیست، فراخوانی کنید. اگر این تابع ``NULL`` برگرداند، هیچ استثنایی مطرح نشده است و فراخوانکننده باید فرض کند که هیچ وضعیت نخی متصل نیست."
msgid ":term:`Attach <attached thread state>` *tstate* to the current thread, which must not be ``NULL`` or already :term:`attached <attached thread state>`."
msgstr "*tstate* را، که نباید ``NULL`` یا از قبل :term:`پیوستشده <attached thread state>` باشد، به نخ فعلی :term:`پیوست میکند <attached thread state>`."
msgid "The calling thread must not already have an :term:`attached thread state`."
msgstr "نخ فراخواننده نباید از قبل یک :term:`attached thread state` داشته باشد."
msgid "Updated to be consistent with :c:func:`PyEval_RestoreThread`, :c:func:`Py_END_ALLOW_THREADS`, and :c:func:`PyGILState_Ensure`, and terminate the current thread if called while the interpreter is finalizing."
msgstr "بهروزرسانی شد تا با :c:func:`PyEval_RestoreThread`، :c:func:`Py_END_ALLOW_THREADS` و :c:func:`PyGILState_Ensure` سازگار باشد و اگر در حین نهاییسازی مفسر فراخوانی شود، نخ جاری را خاتمه میدهد."
msgid ":c:func:`PyEval_RestoreThread` is a higher-level function which is always available (even when threads have not been initialized)."
msgstr ":c:func:`PyEval_RestoreThread` تابعی در سطح بالاتر است که همیشه در دسترس است (حتی زمانی که نخها مقداردهی اولیه نشده باشند)."
msgid "Detach the :term:`attached thread state`. The *tstate* argument, which must not be ``NULL``, is only used to check that it represents the :term:`attached thread state` --- if it isn't, a fatal error is reported."
msgstr ":term:`وضعیت نخ متصل <attached thread state>` را جدا میکند. آرگومان *tstate*، که نباید ``NULL`` باشد، تنها برای بررسی اینکه :term:`وضعیت نخ متصل <attached thread state>` را نمایندگی میکند استفاده میشود --- اگر چنین نباشد، خطای مهلکی گزارش میشود."
msgid ":c:func:`PyEval_SaveThread` is a higher-level function which is always available (even when threads have not been initialized)."
msgstr ":c:func:`PyEval_SaveThread` تابعی در سطح بالاتر است که همیشه دسترسپذیر است (حتی زمانی که نخها مقداردهی اولیه نشده باشند)."
msgid "Asynchronous notifications"
msgstr "اطلاعرسانی ناهمگام"
msgid "A mechanism is provided to make asynchronous notifications to the main interpreter thread. These notifications take the form of a function pointer and a void pointer argument."
msgstr "سازوکاری برای ارسال اعلانهای ناهمگام به نخ اصلی مفسر ارائه شده است. این اعلانها به شکل یک اشارهگر تابع و یک آرگومان اشارهگر void هستند."
msgid "Schedule a function to be called from the main interpreter thread. On success, ``0`` is returned and *func* is queued for being called in the main thread. On failure, ``-1`` is returned without setting any exception."
msgstr "یک تابع را برای فراخوانی از نخ اصلی مفسر زمانبندی میکند. در صورت موفقیت، ``0`` بازگردانده میشود و *func* برای فراخوانی در نخ اصلی در صف قرار میگیرد. در صورت شکست، ``-1`` بدون تنظیم هیچ استثنایی بازگردانده میشود."
msgid "When successfully queued, *func* will be *eventually* called from the main interpreter thread with the argument *arg*. It will be called asynchronously with respect to normally running Python code, but with both these conditions met:"
msgstr "هنگامی که با موفقیت در صف قرار گیرد، *func* *سرانجام* از نخ اصلی مفسر با آرگومان *arg* فراخوانی خواهد شد. این تابع نسبت به کد پایتونی که بهطور عادی در حال اجراست، بهصورت ناهمگام فراخوانی خواهد شد، اما با برآورده شدن هر دوی این شرایط:"
msgid "on a :term:`bytecode` boundary;"
msgstr "در مرز :term:`بایتکد <bytecode>`؛"
msgid "with the main thread holding an :term:`attached thread state` (*func* can therefore use the full C API)."
msgstr "در حالی که نخ اصلی یک :term:`وضعیت نخ متصل <attached thread state>` را در اختیار دارد (*func* در نتیجه میتواند از تمام API زبان C استفاده کند)."
msgid "*func* must return ``0`` on success, or ``-1`` on failure with an exception set. *func* won't be interrupted to perform another asynchronous notification recursively, but it can still be interrupted to switch threads if the :term:`thread state <attached thread state>` is detached."
msgstr "*func* باید در صورت موفقیت ``0`` و در صورت شکست همراه با یک استثنای تنظیمشده ``-1`` را برگرداند. *func* برای انجام اطلاعرسانی ناهمگام دیگری بهصورت بازگشتی قطع نمیشود، اما اگر :term:`وضعیت نخ <attached thread state>` جداشده باشد، همچنان ممکن است برای تعویض نخها قطع شود."
msgid "This function doesn't need an :term:`attached thread state`. However, to call this function in a subinterpreter, the caller must have an :term:`attached thread state`. Otherwise, the function *func* can be scheduled to be called from the wrong interpreter."
msgstr "این تابع به :term:`وضعیت نخ متصل <attached thread state>` نیاز ندارد. با این حال، برای فراخوانی این تابع در یک زیرمفسر، فراخواننده باید :term:`وضعیت نخ متصل <attached thread state>` داشته باشد. در غیر این صورت، ممکن است تابع *func* برای فراخوانی از مفسر اشتباه زمانبندی شود."
msgid "This is a low-level function, only useful for very special cases. There is no guarantee that *func* will be called as quick as possible. If the main thread is busy executing a system call, *func* won't be called before the system call returns. This function is generally **not** suitable for calling Python code from arbitrary C threads. Instead, use the :ref:`PyGILState API<gilstate>`."
msgstr "این یک تابع سطح پایین است که فقط برای موارد بسیار خاص مفید است. هیچ تضمینی وجود ندارد که *func* در سریعترین حالت ممکن فراخوانی شود. اگر نخ اصلی مشغول اجرای یک فراخوانی سیستمی باشد، *func* پیش از بازگشت فراخوانی سیستمی فراخوانی نخواهد شد. این تابع بهطور کلی برای فراخوانی کد پایتون از نخهای C دلخواه مناسب **نیست**. در عوض، از :ref:`PyGILState API<gilstate>` استفاده کنید."
msgid "If this function is called in a subinterpreter, the function *func* is now scheduled to be called from the subinterpreter, rather than being called from the main interpreter. Each subinterpreter now has its own list of scheduled calls."
msgstr "اگر این تابع در یک زیرمفسر فراخوانی شود، تابع *func* اکنون برای فراخوانی از طریق زیرمفسر زمانبندی میشود، نه از طریق مفسر اصلی. هر زیرمفسر اکنون فهرست فراخوانیهای زمانبندیشدهی خود را دارد."
msgid "This function now always schedules *func* to be run in the main interpreter."
msgstr "این تابع اکنون همیشه *func* را برای اجرا در مفسر اصلی زمانبندی میکند."
msgid "Execute all pending calls. This is usually executed automatically by the interpreter."
msgstr "همهی فراخوانیهای در انتظار را اجرا میکند. این کار معمولاً بهطور خودکار توسط مفسر اجرا میشود."
msgid "This function returns ``0`` on success, and returns ``-1`` with an exception set on failure."
msgstr "این تابع در صورت موفقیت ``0`` را بازمیگرداند و در صورت شکست ``-1`` را بههمراه یک استثنای تنظیمشده بازمیگرداند."
msgid "If this is not called in the main thread of the main interpreter, this function does nothing and returns ``0``. The caller must hold an :term:`attached thread state`."
msgstr "اگر این تابع در نخ اصلی مفسر اصلی فراخوانی نشود، این تابع هیچ کاری انجام نمیدهد و ``0`` را برمیگرداند. فراخواننده باید یک :term:`attached thread state` را در اختیار داشته باشد."
msgid "This function only runs pending calls in the main interpreter."
msgstr "این تابع فقط فراخوانیهای در انتظار را در مفسر اصلی اجرا میکند."
msgid "Asynchronously raise an exception in a thread. The *id* argument is the thread id of the target thread; *exc* is the exception object to be raised. This function does not :term:`steal` any references to *exc*. To prevent naive misuse, you must write your own C extension to call this. Must be called with an :term:`attached thread state`. Returns the number of thread states modified; this is normally one, but will be zero if the thread id isn't found. If *exc* is ``NULL``, the pending exception (if any) for the thread is cleared. This raises no exceptions."
msgstr "یک استثنا را بهصورت ناهمگام در یک نخ ایجاد میکند. آرگومان *id* شناسهی نخ هدف است؛ *exc* شیء استثنا است که باید ایجاد شود. این تابع هیچ ارجاعی به *exc* را :term:`سرقت <steal>` نمیکند. برای جلوگیری از سوءاستفادهی سادهلوحانه، باید برای فراخوانی این تابع، افزونهی C خودتان را بنویسید. باید با یک :term:`وضعیت نخ متصل <attached thread state>` فراخوانی شود. تعداد وضعیتهای نخ که تغییر کردهاند را برمیگرداند؛ این تعداد معمولاً یکی است، اما اگر شناسهی نخ پیدا نشود، صفر خواهد بود. اگر *exc* برابر ``NULL`` باشد، استثنای در انتظار (در صورت وجود) برای آن نخ پاک میشود. این تابع هیچ استثنایی ایجاد نمیکند."
msgid "The type of the *id* parameter changed from :c:expr:`long` to :c:expr:`unsigned long`."
msgstr "نوع پارامتر *id* از :c:expr:`long` به :c:expr:`unsigned long` تغییر یافت."
msgid "Operating system thread APIs"
msgstr "APIهای نخ سیستمعامل"
msgid "Sentinel value for an invalid thread ID."
msgstr "مقدار نشانگر برای شناسهی نامعتبر نخ."
msgid "This is currently equivalent to ``(unsigned long)-1``."
msgstr "این در حال حاضر معادل ``(unsigned long)-1`` است."
msgid "Start function *func* in a new thread with argument *arg*. The resulting thread is not intended to be joined."
msgstr "تابع *func* را با آرگومان *arg* در یک نخ جدید آغاز میکند. نخ حاصل برای پیوستن در نظر گرفته نشده است."
msgid "*func* must not be ``NULL``, but *arg* may be ``NULL``."
msgstr "*func* نباید ``NULL`` باشد، اما *arg* میتواند ``NULL`` باشد."
msgid "On success, this function returns the identifier of the new thread; on failure, this returns :c:macro:`PYTHREAD_INVALID_THREAD_ID`."
msgstr "در صورت موفقیت، این تابع شناسهی نخ جدید را برمیگرداند؛ در صورت شکست، :c:macro:`PYTHREAD_INVALID_THREAD_ID` را برمیگرداند."
msgid "The caller does not need to hold an :term:`attached thread state`."
msgstr "فراخواننده نیازی به در اختیار داشتن :term:`attached thread state` ندارد."
msgid "Return the identifier of the current thread, which will never be zero."
msgstr "شناسهی نخ فعلی را برمیگرداند که هرگز صفر نخواهد بود."
msgid "This function cannot fail, and the caller does not need to hold an :term:`attached thread state`."
msgstr "این تابع نمیتواند شکست بخورد و فراخوانیکننده نیازی به نگه داشتن :term:`attached thread state` ندارد."
msgid ":py:func:`threading.get_ident`"
msgstr ":py:func:`threading.get_ident`"
msgid "Get general information about the current thread in the form of a :ref:`struct sequence <struct-sequence-objects>` object. This information is accessible as :py:attr:`sys.thread_info` in Python."
msgstr "اطلاعات کلی دربارهی نخ فعلی را به شکل یک شیء :ref:`دنباله ساختاری <struct-sequence-objects>` دریافت کنید. این اطلاعات در پایتون به صورت :py:attr:`sys.thread_info` در دسترس است."
msgid "On success, this returns a new :term:`strong reference` to the thread information; on failure, this returns ``NULL`` with an exception set."
msgstr "در صورت موفقیت، یک :term:`ارجاع قوی <strong reference>` جدید به اطلاعات نخ بازگردانده میشود؛ در صورت شکست، ``NULL`` همراه با یک استثنای تنظیمشده بازگردانده میشود."
msgid "The caller must hold an :term:`attached thread state`."
msgstr "فراخواننده باید یک :term:`attached thread state` را در اختیار داشته باشد."
msgid "This macro is defined when the system supports native thread IDs."
msgstr "این ماکرو زمانی تعریف میشود که سیستم از شناسههای نخ بومی پشتیبانی کند."
msgid "Get the native identifier of the current thread as it was assigned by the operating system's kernel, which will never be less than zero."
msgstr "شناسه بومی نخ فعلی را همانطور که توسط هسته سیستمعامل به آن اختصاص داده شده است به دست میآورد؛ این شناسه هرگز کمتر از صفر نخواهد بود."
msgid "This function is only available when :c:macro:`PY_HAVE_THREAD_NATIVE_ID` is defined."
msgstr "این تابع تنها زمانی دسترسپذیر است که :c:macro:`PY_HAVE_THREAD_NATIVE_ID` تعریفشده باشد."
msgid ":py:func:`threading.get_native_id`"
msgstr ":py:func:`threading.get_native_id`"
msgid "Terminate the current thread. This function is generally considered unsafe and should be avoided. It is kept solely for backwards compatibility."
msgstr "نخ فعلی را خاتمه میدهد. این تابع بهطور کلی ناامن تلقی میشود و باید از آن پرهیز کرد. این تابع صرفاً برای سازگاری با نسخههای پیشین نگهداشته شده است."
msgid "This function is only safe to call if all functions in the full call stack are written to safely allow it."
msgstr "فراخوانی این تابع تنها زمانی ایمن است که تمام توابع در کل پشته فراخوانی، بهگونهای نوشته شده باشند که بهصورت ایمن اجازهی آن را بدهند."
msgid "If the current system uses POSIX threads (also known as \"pthreads\"), this calls :manpage:`pthread_exit(3)`, which attempts to unwind the stack and call C++ destructors on some libc implementations. However, if a ``noexcept`` function is reached, it may terminate the process. Other systems, such as macOS, do unwinding."
msgstr "اگر سیستم فعلی از نخهای POSIX (که با نام «pthreads» نیز شناخته میشوند) استفاده کند، این تابع :manpage:`pthread_exit(3)` را فراخوانی میکند که تلاش میکند واپیمایش پشته (stack unwinding) را انجام دهد و در برخی پیادهسازیهای libc مخربهای C++ را فراخوانی کند. اما اگر به یک تابع ``noexcept`` برسد، ممکن است فرایند را خاتمه دهد. سایر سیستمها مانند macOS واپیمایش پشته را انجام میدهند."
msgid "On Windows, this function calls ``_endthreadex()``, which kills the thread without calling C++ destructors."
msgstr "در ویندوز، این تابع ``_endthreadex()`` را فراخوانی میکند که نخ را بدون فراخوانی مخربهای C++ میکشد."
msgid "In any case, there is a risk of corruption on the thread's stack."
msgstr "در هر صورت، خطر خرابی پشتهی نخ وجود دارد."
msgid "Initialize ``PyThread*`` APIs. Python executes this function automatically, so there's little need to call it from an extension module."
msgstr "APIهای ``PyThread*`` را مقداردهی اولیه میکند. پایتون این تابع را بهطور خودکار اجرا میکند، بنابراین نیاز چندانی به فراخوانی آن از یک ماژول توسعهای وجود ندارد."
msgid "Set the stack size of the current thread to *size* bytes."
msgstr "اندازه پشتهی نخ فعلی را روی *size* بایت تنظیم میکند."
msgid "This function returns ``0`` on success, ``-1`` if *size* is invalid, or ``-2`` if the system does not support changing the stack size. This function does not set exceptions."
msgstr "این تابع در صورت موفقیت ``0``، در صورت نامعتبر بودن *size* مقدار ``-1``، یا در صورتی که سیستم از تغییر اندازه پشته پشتیبانی نکند ``-2`` برمیگرداند. این تابع استثنایی تنظیم نمیکند."
msgid "Return the stack size of the current thread in bytes, or ``0`` if the system's default stack size is in use."
msgstr "اندازه پشته نخ فعلی را بر حسب بایت برمیگرداند، یا ``0`` اگر اندازه پشته پیشفرض سیستم در حال استفاده باشد."
msgid "global interpreter lock"
msgstr "قفل مفسر سراسری"
msgid "interpreter lock"
msgstr "قفل مفسر"
msgid "lock, interpreter"
msgstr "قفل، مفسر"
msgid "setswitchinterval (in module sys)"
msgstr "setswitchinterval (در ماژول sys)"
msgid "PyThreadState (C type)"
msgstr "PyThreadState (نوع C)"
msgid "Py_BEGIN_ALLOW_THREADS (C macro)"
msgstr "Py_BEGIN_ALLOW_THREADS (ماکروی C)"
msgid "Py_END_ALLOW_THREADS (C macro)"
msgstr "Py_END_ALLOW_THREADS (ماکروی C)"
msgid "PyEval_RestoreThread (C function)"
msgstr "PyEval_RestoreThread (تابع C)"
msgid "PyEval_SaveThread (C function)"
msgstr "PyEval_SaveThread (تابع C)"
msgid "PyEval_AcquireThread()"
msgstr "PyEval_AcquireThread()"
msgid "PyEval_ReleaseThread()"
msgstr "PyEval_ReleaseThread()"
msgid "PyEval_SaveThread()"
msgstr "PyEval_SaveThread()"
msgid "PyEval_RestoreThread()"
msgstr "PyEval_RestoreThread()"
msgid "module"
msgstr "ماژول"
msgid "_thread"
msgstr "_thread"