@vercel/python 4.2.0 → 4.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +2 -2
- package/vc_init.py +14 -4
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vercel/python",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.3.0",
|
|
4
4
|
"main": "./dist/index.js",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"homepage": "https://vercel.com/docs/runtimes#official-runtimes/python",
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"@types/jest": "27.4.1",
|
|
20
20
|
"@types/node": "14.18.33",
|
|
21
21
|
"@types/which": "3.0.0",
|
|
22
|
-
"@vercel/build-utils": "
|
|
22
|
+
"@vercel/build-utils": "8.2.1",
|
|
23
23
|
"execa": "^1.0.0",
|
|
24
24
|
"fs-extra": "11.1.1",
|
|
25
25
|
"jest-junit": "16.0.0",
|
package/vc_init.py
CHANGED
|
@@ -13,6 +13,7 @@ sys.modules["__VC_HANDLER_MODULE_NAME"] = __vc_module
|
|
|
13
13
|
__vc_spec.loader.exec_module(__vc_module)
|
|
14
14
|
__vc_variables = dir(__vc_module)
|
|
15
15
|
|
|
16
|
+
_use_legacy_asyncio = sys.version_info < (3, 10)
|
|
16
17
|
|
|
17
18
|
def format_headers(headers, decode=False):
|
|
18
19
|
keyToList = {}
|
|
@@ -198,16 +199,25 @@ elif 'app' in __vc_variables:
|
|
|
198
199
|
ASGI instance using the connection scope.
|
|
199
200
|
Runs until the response is completely read from the application.
|
|
200
201
|
"""
|
|
201
|
-
|
|
202
|
-
|
|
202
|
+
if _use_legacy_asyncio:
|
|
203
|
+
loop = asyncio.new_event_loop()
|
|
204
|
+
self.app_queue = asyncio.Queue(loop=loop)
|
|
205
|
+
else:
|
|
206
|
+
self.app_queue = asyncio.Queue()
|
|
203
207
|
self.put_message({'type': 'http.request', 'body': body, 'more_body': False})
|
|
204
208
|
|
|
205
209
|
asgi_instance = app(self.scope, self.receive, self.send)
|
|
206
210
|
|
|
207
|
-
|
|
208
|
-
|
|
211
|
+
if _use_legacy_asyncio:
|
|
212
|
+
asgi_task = loop.create_task(asgi_instance)
|
|
213
|
+
loop.run_until_complete(asgi_task)
|
|
214
|
+
else:
|
|
215
|
+
asyncio.run(self.run_asgi_instance(asgi_instance))
|
|
209
216
|
return self.response
|
|
210
217
|
|
|
218
|
+
async def run_asgi_instance(self, asgi_instance):
|
|
219
|
+
await asgi_instance
|
|
220
|
+
|
|
211
221
|
def put_message(self, message):
|
|
212
222
|
self.app_queue.put_nowait(message)
|
|
213
223
|
|