@vercel/python 4.2.0 → 4.3.1

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/dist/index.js CHANGED
@@ -3088,6 +3088,10 @@ var build = async ({
3088
3088
  const files = await (0, import_build_utils3.glob)("**", globOptions);
3089
3089
  const handlerPyFilename = "vc__handler__python";
3090
3090
  files[`${handlerPyFilename}.py`] = new import_build_utils3.FileBlob({ data: handlerPyContents });
3091
+ if (config.framework === "fasthtml") {
3092
+ const { SESSKEY = "" } = process.env;
3093
+ files[".sesskey"] = new import_build_utils3.FileBlob({ data: `"${SESSKEY}"` });
3094
+ }
3091
3095
  const output = new import_build_utils3.Lambda({
3092
3096
  files,
3093
3097
  handler: `${handlerPyFilename}.vc_handler`,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vercel/python",
3
- "version": "4.2.0",
3
+ "version": "4.3.1",
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": "7.12.0",
22
+ "@vercel/build-utils": "8.3.5",
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
- loop = asyncio.new_event_loop()
202
- self.app_queue = asyncio.Queue(loop=loop)
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
- asgi_task = loop.create_task(asgi_instance)
208
- loop.run_until_complete(asgi_task)
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