88msgstr ""
99"Project-Id-Version : Flask 2.1.x\n "
1010"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 "
1212"PO-Revision-Date : YEAR-MO-DA HO:MI+ZONE\n "
1313"Last-Translator : FULL NAME <EMAIL@ADDRESS>\n "
1414"
Language-Team :
zh_CN <[email protected] >\n "
@@ -25,34 +25,35 @@ msgstr ""
2525msgid ""
2626"Routes, error handlers, before request, after request, and teardown "
2727"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 "
2930"defined with ``async def`` and use ``await``."
3031msgstr ""
3132
32- #: ../../async-await.rst:20
33+ #: ../../async-await.rst:21
3334msgid "Using ``async`` on Windows on Python 3.8"
3435msgstr ""
3536
36- #: ../../async-await.rst:22
37+ #: ../../async-await.rst:23
3738msgid ""
3839"Python 3.8 has a bug related to asyncio on Windows. If you encounter "
3940"something like ``ValueError: set_wakeup_fd only works in main thread``, "
4041"please upgrade to Python 3.9."
4142msgstr ""
4243
43- #: ../../async-await.rst:28
44+ #: ../../async-await.rst:29
4445msgid "Performance"
4546msgstr ""
4647
47- #: ../../async-await.rst:30
48+ #: ../../async-await.rst:31
4849msgid ""
4950"Async functions require an event loop to run. Flask, as a WSGI "
5051"application, uses one worker to handle one request/response cycle. When a"
5152" request comes in to an async view, Flask will start an event loop in a "
5253"thread, run the view function there, then return the result."
5354msgstr ""
5455
55- #: ../../async-await.rst:35
56+ #: ../../async-await.rst:36
5657msgid ""
5758"Each request still ties up one worker, even for async views. The upside "
5859"is that you can run async code within a view, for example to make "
@@ -61,7 +62,7 @@ msgid ""
6162"time will remain the same."
6263msgstr ""
6364
64- #: ../../async-await.rst:41
65+ #: ../../async-await.rst:42
6566msgid ""
6667"**Async is not inherently faster than sync code.** Async is beneficial "
6768"when performing concurrent IO-bound tasks, but will probably not improve "
@@ -70,11 +71,11 @@ msgid ""
7071"that wasn't possible natively before."
7172msgstr ""
7273
73- #: ../../async-await.rst:49
74+ #: ../../async-await.rst:50
7475msgid "Background tasks"
7576msgstr ""
7677
77- #: ../../async-await.rst:51
78+ #: ../../async-await.rst:52
7879msgid ""
7980"Async functions will run in an event loop until they complete, at which "
8081"stage the event loop will stop. This means any additional spawned tasks "
@@ -83,7 +84,7 @@ msgid ""
8384"``asyncio.create_task``."
8485msgstr ""
8586
86- #: ../../async-await.rst:57
87+ #: ../../async-await.rst:58
8788msgid ""
8889"If you wish to use background tasks it is best to use a task queue to "
8990"trigger background work, rather than spawn tasks in a view function. With"
@@ -93,11 +94,11 @@ msgid ""
9394"continually."
9495msgstr ""
9596
96- #: ../../async-await.rst:66
97+ #: ../../async-await.rst:67
9798msgid "When to use Quart instead"
9899msgstr ""
99100
100- #: ../../async-await.rst:68
101+ #: ../../async-await.rst:69
101102msgid ""
102103"Flask's async support is less performant than async-first frameworks due "
103104"to the way it is implemented. If you have a mainly async codebase it "
@@ -107,7 +108,7 @@ msgid ""
107108"without requiring multiple worker processes or threads."
108109msgstr ""
109110
110- #: ../../async-await.rst:75
111+ #: ../../async-await.rst:76
111112msgid ""
112113"It has also already been possible to run Flask with Gevent or Eventlet to"
113114" get many of the benefits of async request handling. These libraries "
@@ -117,11 +118,11 @@ msgid ""
117118"to understanding the specific needs of your project."
118119msgstr ""
119120
120- #: ../../async-await.rst:87
121+ #: ../../async-await.rst:88
121122msgid "Extensions"
122123msgstr ""
123124
124- #: ../../async-await.rst:89
125+ #: ../../async-await.rst:90
125126msgid ""
126127"Flask extensions predating Flask's async support do not expect async "
127128"views. If they provide decorators to add functionality to views, those "
@@ -131,28 +132,38 @@ msgid ""
131132"view."
132133msgstr ""
133134
134- #: ../../async-await.rst:95
135+ #: ../../async-await.rst:96
135136msgid ""
136137"Extension authors can support async functions by utilising the "
137138":meth:`flask.Flask.ensure_sync` method. For example, if the extension "
138139"provides a view function decorator add ``ensure_sync`` before calling the"
139140" decorated function,"
140141msgstr ""
141142
142- #: ../../async-await.rst:110
143+ #: ../../async-await.rst:111
143144msgid ""
144145"Check the changelog of the extension you want to use to see if they've "
145146"implemented async support, or make a feature request or PR to them."
146147msgstr ""
147148
148- #: ../../async-await.rst:115
149+ #: ../../async-await.rst:116
149150msgid "Other event loops"
150151msgstr ""
151152
152- #: ../../async-await.rst:117
153+ #: ../../async-await.rst:118
153154msgid ""
154155"At the moment Flask only supports :mod:`asyncio`. It's possible to "
155156"override :meth:`flask.Flask.ensure_sync` to change how async functions "
156157"are wrapped to use a different library."
157158msgstr ""
158159
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