-
-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathcontextvars.po
More file actions
319 lines (268 loc) · 9.11 KB
/
contextvars.po
File metadata and controls
319 lines (268 loc) · 9.11 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
# SOME DESCRIPTIVE TITLE.
# Copyright (C) 2001-2026, Python Software Foundation
# This file is distributed under the same license as the Python package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
# Translators:
# Rafael Fontenelle <rffontenelle@gmail.com>, 2025
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: Python 3.12\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2026-03-17 16:36+0000\n"
"PO-Revision-Date: 2025-07-18 19:57+0000\n"
"Last-Translator: Rafael Fontenelle <rffontenelle@gmail.com>, 2025\n"
"Language-Team: Polish (https://app.transifex.com/python-doc/teams/5390/pl/)\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Language: pl\n"
"Plural-Forms: nplurals=4; plural=(n==1 ? 0 : (n%10>=2 && n%10<=4) && "
"(n%100<12 || n%100>14) ? 1 : n!=1 && (n%10>=0 && n%10<=1) || (n%10>=5 && "
"n%10<=9) || (n%100>=12 && n%100<=14) ? 2 : 3);\n"
msgid ":mod:`!contextvars` --- Context Variables"
msgstr ""
msgid ""
"This module provides APIs to manage, store, and access context-local state. "
"The :class:`~contextvars.ContextVar` class is used to declare and work with "
"*Context Variables*. The :func:`~contextvars.copy_context` function and "
"the :class:`~contextvars.Context` class should be used to manage the current "
"context in asynchronous frameworks."
msgstr ""
msgid ""
"Context managers that have state should use Context Variables instead of :"
"func:`threading.local` to prevent their state from bleeding to other code "
"unexpectedly, when used in concurrent code."
msgstr ""
msgid "See also :pep:`567` for additional details."
msgstr ""
msgid "Context Variables"
msgstr ""
msgid "This class is used to declare a new Context Variable, e.g.::"
msgstr ""
msgid "var: ContextVar[int] = ContextVar('var', default=42)"
msgstr ""
msgid ""
"The required *name* parameter is used for introspection and debug purposes."
msgstr ""
msgid ""
"The optional keyword-only *default* parameter is returned by :meth:"
"`ContextVar.get` when no value for the variable is found in the current "
"context."
msgstr ""
msgid ""
"**Important:** Context Variables should be created at the top module level "
"and never in closures. :class:`Context` objects hold strong references to "
"context variables which prevents context variables from being properly "
"garbage collected."
msgstr ""
msgid "The name of the variable. This is a read-only property."
msgstr ""
msgid "Return a value for the context variable for the current context."
msgstr ""
msgid ""
"If there is no value for the variable in the current context, the method "
"will:"
msgstr ""
msgid ""
"return the value of the *default* argument of the method, if provided; or"
msgstr ""
msgid ""
"return the default value for the context variable, if it was created with "
"one; or"
msgstr ""
msgid "raise a :exc:`LookupError`."
msgstr ""
msgid ""
"Call to set a new value for the context variable in the current context."
msgstr ""
msgid ""
"The required *value* argument is the new value for the context variable."
msgstr ""
msgid ""
"Returns a :class:`~contextvars.Token` object that can be used to restore the "
"variable to its previous value via the :meth:`ContextVar.reset` method."
msgstr ""
msgid ""
"Reset the context variable to the value it had before the :meth:`ContextVar."
"set` that created the *token* was used."
msgstr ""
msgid "For example::"
msgstr "Dla przykładu::"
msgid ""
"var = ContextVar('var')\n"
"\n"
"token = var.set('new value')\n"
"# code that uses 'var'; var.get() returns 'new value'.\n"
"var.reset(token)\n"
"\n"
"# After the reset call the var has no value again, so\n"
"# var.get() would raise a LookupError."
msgstr ""
msgid ""
"*Token* objects are returned by the :meth:`ContextVar.set` method. They can "
"be passed to the :meth:`ContextVar.reset` method to revert the value of the "
"variable to what it was before the corresponding *set*."
msgstr ""
msgid ""
"A read-only property. Points to the :class:`ContextVar` object that created "
"the token."
msgstr ""
msgid ""
"A read-only property. Set to the value the variable had before the :meth:"
"`ContextVar.set` method call that created the token. It points to :attr:"
"`Token.MISSING` if the variable was not set before the call."
msgstr ""
msgid "A marker object used by :attr:`Token.old_value`."
msgstr ""
msgid "Manual Context Management"
msgstr ""
msgid "Returns a copy of the current :class:`~contextvars.Context` object."
msgstr ""
msgid ""
"The following snippet gets a copy of the current context and prints all "
"variables and their values that are set in it::"
msgstr ""
msgid ""
"ctx: Context = copy_context()\n"
"print(list(ctx.items()))"
msgstr ""
msgid ""
"The function has an *O*\\ (1) complexity, i.e. works equally fast for "
"contexts with a few context variables and for contexts that have a lot of "
"them."
msgstr ""
msgid "A mapping of :class:`ContextVars <ContextVar>` to their values."
msgstr ""
msgid ""
"``Context()`` creates an empty context with no values in it. To get a copy "
"of the current context use the :func:`~contextvars.copy_context` function."
msgstr ""
msgid ""
"Every thread will have a different top-level :class:`~contextvars.Context` "
"object. This means that a :class:`ContextVar` object behaves in a similar "
"fashion to :func:`threading.local` when values are assigned in different "
"threads."
msgstr ""
msgid "Context implements the :class:`collections.abc.Mapping` interface."
msgstr ""
msgid ""
"Execute ``callable(*args, **kwargs)`` code in the context object the *run* "
"method is called on. Return the result of the execution or propagate an "
"exception if one occurred."
msgstr ""
msgid ""
"Any changes to any context variables that *callable* makes will be contained "
"in the context object::"
msgstr ""
msgid ""
"var = ContextVar('var')\n"
"var.set('spam')\n"
"\n"
"def main():\n"
" # 'var' was set to 'spam' before\n"
" # calling 'copy_context()' and 'ctx.run(main)', so:\n"
" # var.get() == ctx[var] == 'spam'\n"
"\n"
" var.set('ham')\n"
"\n"
" # Now, after setting 'var' to 'ham':\n"
" # var.get() == ctx[var] == 'ham'\n"
"\n"
"ctx = copy_context()\n"
"\n"
"# Any changes that the 'main' function makes to 'var'\n"
"# will be contained in 'ctx'.\n"
"ctx.run(main)\n"
"\n"
"# The 'main()' function was run in the 'ctx' context,\n"
"# so changes to 'var' are contained in it:\n"
"# ctx[var] == 'ham'\n"
"\n"
"# However, outside of 'ctx', 'var' is still set to 'spam':\n"
"# var.get() == 'spam'"
msgstr ""
msgid ""
"The method raises a :exc:`RuntimeError` when called on the same context "
"object from more than one OS thread, or when called recursively."
msgstr ""
msgid "Return a shallow copy of the context object."
msgstr ""
msgid ""
"Return ``True`` if the *context* has a value for *var* set; return ``False`` "
"otherwise."
msgstr ""
msgid ""
"Return the value of the *var* :class:`ContextVar` variable. If the variable "
"is not set in the context object, a :exc:`KeyError` is raised."
msgstr ""
msgid ""
"Return the value for *var* if *var* has the value in the context object. "
"Return *default* otherwise. If *default* is not given, return ``None``."
msgstr ""
msgid "Return an iterator over the variables stored in the context object."
msgstr ""
msgid "Return the number of variables set in the context object."
msgstr ""
msgid "Return a list of all variables in the context object."
msgstr ""
msgid "Return a list of all variables' values in the context object."
msgstr ""
msgid ""
"Return a list of 2-tuples containing all variables and their values in the "
"context object."
msgstr ""
msgid "asyncio support"
msgstr ""
msgid ""
"Context variables are natively supported in :mod:`asyncio` and are ready to "
"be used without any extra configuration. For example, here is a simple echo "
"server, that uses a context variable to make the address of a remote client "
"available in the Task that handles that client::"
msgstr ""
msgid ""
"import asyncio\n"
"import contextvars\n"
"\n"
"client_addr_var = contextvars.ContextVar('client_addr')\n"
"\n"
"def render_goodbye():\n"
" # The address of the currently handled client can be accessed\n"
" # without passing it explicitly to this function.\n"
"\n"
" client_addr = client_addr_var.get()\n"
" return f'Good bye, client @ {client_addr}\\r\\n'.encode()\n"
"\n"
"async def handle_request(reader, writer):\n"
" addr = writer.transport.get_extra_info('socket').getpeername()\n"
" client_addr_var.set(addr)\n"
"\n"
" # In any code that we call is now possible to get\n"
" # client's address by calling 'client_addr_var.get()'.\n"
"\n"
" while True:\n"
" line = await reader.readline()\n"
" print(line)\n"
" if not line.strip():\n"
" break\n"
"\n"
" writer.write(b'HTTP/1.1 200 OK\\r\\n') # status line\n"
" writer.write(b'\\r\\n') # headers\n"
" writer.write(render_goodbye()) # body\n"
" writer.close()\n"
"\n"
"async def main():\n"
" srv = await asyncio.start_server(\n"
" handle_request, '127.0.0.1', 8081)\n"
"\n"
" async with srv:\n"
" await srv.serve_forever()\n"
"\n"
"asyncio.run(main())\n"
"\n"
"# To test it you can use telnet or curl:\n"
"# telnet 127.0.0.1 8081\n"
"# curl 127.0.0.1:8081"
msgstr ""