Ошибка
Код: Выделить всё
{
"errorMessage": "Syntax error in module 'lambda_function': invalid syntax (base_events.py, line 296)",
"errorType": "Runtime.UserCodeSyntaxError",
"requestId": "",
"stackTrace": [
" File \"/function/asyncio/base_events.py\" Line 296\n future = tasks.async(future, loop=self)\n"
]
}
Код: Выделить всё
# # Define function directory
ARG FUNCTION_DIR="/function"
FROM mcr.microsoft.com/playwright/python:v1.49.0-noble as build-image
# Install aws-lambda-cpp build dependencies
RUN apt-get update && \
apt-get install -y \
g++ \
make \
cmake \
unzip \
libcurl4-openssl-dev
# Include global arg in this stage of the build
ARG FUNCTION_DIR
# Create function directory
RUN mkdir -p ${FUNCTION_DIR}
# Copy function code
COPY . ${FUNCTION_DIR}
# Install the runtime interface client
RUN pip3 install \
--target ${FUNCTION_DIR} \
-r /function/requirements.txt
# Multi-stage build: grab a fresh copy of the base image
FROM mcr.microsoft.com/playwright/python:v1.49.0-noble
# Include global arg in this stage of the build
ARG FUNCTION_DIR
# Set working directory to function root directory
WORKDIR ${FUNCTION_DIR}
# Copy in the build image dependencies
COPY --from=build-image ${FUNCTION_DIR} ${FUNCTION_DIR}
ENTRYPOINT [ "/usr/bin/python", "-m", "awslambdaric" ]
CMD [ "lambda_function.handler" ]
Код: Выделить всё
asyncio==3.4.3
awslambdaric==2.2.1
boto3==1.35.49
botocore==1.35.49
certifi==2024.8.30
charset-normalizer==3.4.0
colorama==0.4.6
exceptiongroup==1.2.2
greenlet==3.1.1
idna==3.10
iniconfig==2.0.0
jmespath==1.0.1
packaging==24.1
playwright==1.49.0
pluggy==1.5.0
pyee==12.0.0
pytest==8.3.3
pytest-base-url==2.1.0
pytest-playwright==0.5.2
python-dateutil==2.9.0.post0
python-slugify==8.0.4
requests==2.32.3
s3transfer==0.10.3
simplejson==3.19.3
six==1.16.0
text-unidecode==1.3
tomli==2.0.2
typing_extensions==4.12.2
urllib3==2.2.3
websockets==10.1
Код: Выделить всё
from playwright.sync_api import sync_playwright
def handler(event, context):
with sync_playwright() as p:
browser = p.chromium.launch(headless=True)
page = browser.new_page()
page.goto("http://example.com/")
browser.close()
return("finished")
Подробнее здесь: https://stackoverflow.com/questions/792 ... -playwrigh