8
8
msgstr ""
9
9
"Project-Id-Version : Flask 2.1.x\n "
10
10
"Report-Msgid-Bugs-To : \n "
11
- "POT-Creation-Date : 2021-05-25 19:31+0800 \n "
11
+ "POT-Creation-Date : 2021-05-30 19:27+0000 \n "
12
12
"PO-Revision-Date : YEAR-MO-DA HO:MI+ZONE\n "
13
13
"Last-Translator : FULL NAME <EMAIL@ADDRESS>\n "
14
14
"
Language-Team :
zh_CN <[email protected] >\n "
@@ -25,34 +25,35 @@ msgstr ""
25
25
msgid ""
26
26
"Routes, error handlers, before request, after request, and teardown "
27
27
"functions can all be coroutine functions if Flask is installed with the "
28
- "``async`` extra (``pip install flask[async]``). This allows views to be "
28
+ "``async`` extra (``pip install flask[async]``). It requires Python 3.7+ "
29
+ "where ``contextvars.ContextVar`` is available. This allows views to be "
29
30
"defined with ``async def`` and use ``await``."
30
31
msgstr ""
31
32
32
- #: ../../async-await.rst:20
33
+ #: ../../async-await.rst:21
33
34
msgid "Using ``async`` on Windows on Python 3.8"
34
35
msgstr ""
35
36
36
- #: ../../async-await.rst:22
37
+ #: ../../async-await.rst:23
37
38
msgid ""
38
39
"Python 3.8 has a bug related to asyncio on Windows. If you encounter "
39
40
"something like ``ValueError: set_wakeup_fd only works in main thread``, "
40
41
"please upgrade to Python 3.9."
41
42
msgstr ""
42
43
43
- #: ../../async-await.rst:28
44
+ #: ../../async-await.rst:29
44
45
msgid "Performance"
45
46
msgstr ""
46
47
47
- #: ../../async-await.rst:30
48
+ #: ../../async-await.rst:31
48
49
msgid ""
49
50
"Async functions require an event loop to run. Flask, as a WSGI "
50
51
"application, uses one worker to handle one request/response cycle. When a"
51
52
" request comes in to an async view, Flask will start an event loop in a "
52
53
"thread, run the view function there, then return the result."
53
54
msgstr ""
54
55
55
- #: ../../async-await.rst:35
56
+ #: ../../async-await.rst:36
56
57
msgid ""
57
58
"Each request still ties up one worker, even for async views. The upside "
58
59
"is that you can run async code within a view, for example to make "
@@ -61,7 +62,7 @@ msgid ""
61
62
"time will remain the same."
62
63
msgstr ""
63
64
64
- #: ../../async-await.rst:41
65
+ #: ../../async-await.rst:42
65
66
msgid ""
66
67
"**Async is not inherently faster than sync code.** Async is beneficial "
67
68
"when performing concurrent IO-bound tasks, but will probably not improve "
@@ -70,11 +71,11 @@ msgid ""
70
71
"that wasn't possible natively before."
71
72
msgstr ""
72
73
73
- #: ../../async-await.rst:49
74
+ #: ../../async-await.rst:50
74
75
msgid "Background tasks"
75
76
msgstr ""
76
77
77
- #: ../../async-await.rst:51
78
+ #: ../../async-await.rst:52
78
79
msgid ""
79
80
"Async functions will run in an event loop until they complete, at which "
80
81
"stage the event loop will stop. This means any additional spawned tasks "
@@ -83,7 +84,7 @@ msgid ""
83
84
"``asyncio.create_task``."
84
85
msgstr ""
85
86
86
- #: ../../async-await.rst:57
87
+ #: ../../async-await.rst:58
87
88
msgid ""
88
89
"If you wish to use background tasks it is best to use a task queue to "
89
90
"trigger background work, rather than spawn tasks in a view function. With"
@@ -93,11 +94,11 @@ msgid ""
93
94
"continually."
94
95
msgstr ""
95
96
96
- #: ../../async-await.rst:66
97
+ #: ../../async-await.rst:67
97
98
msgid "When to use Quart instead"
98
99
msgstr ""
99
100
100
- #: ../../async-await.rst:68
101
+ #: ../../async-await.rst:69
101
102
msgid ""
102
103
"Flask's async support is less performant than async-first frameworks due "
103
104
"to the way it is implemented. If you have a mainly async codebase it "
@@ -107,7 +108,7 @@ msgid ""
107
108
"without requiring multiple worker processes or threads."
108
109
msgstr ""
109
110
110
- #: ../../async-await.rst:75
111
+ #: ../../async-await.rst:76
111
112
msgid ""
112
113
"It has also already been possible to run Flask with Gevent or Eventlet to"
113
114
" get many of the benefits of async request handling. These libraries "
@@ -117,11 +118,11 @@ msgid ""
117
118
"to understanding the specific needs of your project."
118
119
msgstr ""
119
120
120
- #: ../../async-await.rst:87
121
+ #: ../../async-await.rst:88
121
122
msgid "Extensions"
122
123
msgstr ""
123
124
124
- #: ../../async-await.rst:89
125
+ #: ../../async-await.rst:90
125
126
msgid ""
126
127
"Flask extensions predating Flask's async support do not expect async "
127
128
"views. If they provide decorators to add functionality to views, those "
@@ -131,28 +132,38 @@ msgid ""
131
132
"view."
132
133
msgstr ""
133
134
134
- #: ../../async-await.rst:95
135
+ #: ../../async-await.rst:96
135
136
msgid ""
136
137
"Extension authors can support async functions by utilising the "
137
138
":meth:`flask.Flask.ensure_sync` method. For example, if the extension "
138
139
"provides a view function decorator add ``ensure_sync`` before calling the"
139
140
" decorated function,"
140
141
msgstr ""
141
142
142
- #: ../../async-await.rst:110
143
+ #: ../../async-await.rst:111
143
144
msgid ""
144
145
"Check the changelog of the extension you want to use to see if they've "
145
146
"implemented async support, or make a feature request or PR to them."
146
147
msgstr ""
147
148
148
- #: ../../async-await.rst:115
149
+ #: ../../async-await.rst:116
149
150
msgid "Other event loops"
150
151
msgstr ""
151
152
152
- #: ../../async-await.rst:117
153
+ #: ../../async-await.rst:118
153
154
msgid ""
154
155
"At the moment Flask only supports :mod:`asyncio`. It's possible to "
155
156
"override :meth:`flask.Flask.ensure_sync` to change how async functions "
156
157
"are wrapped to use a different library."
157
158
msgstr ""
158
159
160
+ #~ msgid ""
161
+ #~ "Routes, error handlers, before request, "
162
+ #~ "after request, and teardown functions "
163
+ #~ "can all be coroutine functions if "
164
+ #~ "Flask is installed with the ``async``"
165
+ #~ " extra (``pip install flask[async]``). This"
166
+ #~ " allows views to be defined with "
167
+ #~ "``async def`` and use ``await``."
168
+ #~ msgstr ""
169
+
0 commit comments