Wondering if you had success running start-api
- I am using ptvsd
❯ sam local start-api
Mounting FastapiExampleLambda at http://127.0.0.1:3000/{proxy+} [DELETE, GET, HEAD, OPTIONS, PATCH, POST, PUT]
You can now browse to the above endpoints to invoke your functions. You do not need to restart/reload SAM CLI while working on your functions, changes will be reflected instantly/automatically. You only need to restart SAM CLI if you update your AWS SAM template
2020-08-22 15:47:14 * Running on http://127.0.0.1:3000/ (Press CTRL+C to quit)
Invoking example_app.main.handler (python3.8)
Failed to download a new amazon/aws-sam-cli-emulation-image-python3.8:rapid-1.0.0 image. Invoking with the already downloaded image.
Mounting /Users/dwbelliston/code/learn/fastapi-aws-lambda-example/.aws-sam/build/FastapiExampleLambda as /var/task:ro,delegated inside runtime container
START RequestId: 19059eac-f60f-13d2-72c7-e958e53e642e Version: $LATEST
[INFO] 2020-08-22T21:47:22.342Z 19059eac-f60f-13d2-72c7-e958e53e642e Waiting for application startup.
[INFO] 2020-08-22T21:47:22.342Z 19059eac-f60f-13d2-72c7-e958e53e642e LifespanCycleState.STARTUP: 'lifespan.startup.complete' event received from application.
[INFO] 2020-08-22T21:47:22.343Z 19059eac-f60f-13d2-72c7-e958e53e642e Application startup complete.
[INFO] 2020-08-22T21:47:22.343Z 19059eac-f60f-13d2-72c7-e958e53e642e HTTP event received.
[INFO] 2020-08-22T21:47:23.92Z 19059eac-f60f-13d2-72c7-e958e53e642e HTTPCycleState.REQUEST: 'http.response.start' event received from application.
[INFO] 2020-08-22T21:47:23.92Z 19059eac-f60f-13d2-72c7-e958e53e642e HTTPCycleState.RESPONSE: 'http.response.body' event received from application.
[ERROR] 2020-08-22T21:47:23.92Z 19059eac-f60f-13d2-72c7-e958e53e642e Exception in 'http' protocol.
Traceback (most recent call last):
File "/var/task/mangum/protocols/http.py", line 79, in run
await app(self.scope, self.receive, self.send)
File "/var/task/fastapi/applications.py", line 179, in __call__
await super().__call__(scope, receive, send)
File "/var/task/starlette/applications.py", line 111, in __call__
await self.middleware_stack(scope, receive, send)
File "/var/task/starlette/middleware/errors.py", line 181, in __call__
raise exc from None
File "/var/task/starlette/middleware/errors.py", line 159, in __call__
await self.app(scope, receive, _send)
File "/var/task/starlette/exceptions.py", line 82, in __call__
raise exc from None
File "/var/task/starlette/exceptions.py", line 71, in __call__
await self.app(scope, receive, sender)
File "/var/task/starlette/routing.py", line 566, in __call__
await route.handle(scope, receive, send)
File "/var/task/starlette/routing.py", line 227, in handle
await self.app(scope, receive, send)
File "/var/task/starlette/routing.py", line 41, in app
response = await func(request)
File "/var/task/fastapi/routing.py", line 182, in app
raw_response = await run_endpoint_function(
File "/var/task/fastapi/routing.py", line 135, in run_endpoint_function
return await run_in_threadpool(dependant.call, **values)
File "/var/task/starlette/concurrency.py", line 34, in run_in_threadpool
return await loop.run_in_executor(None, func, *args)
File "/var/lang/lib/python3.8/concurrent/futures/thread.py", line 57, in run
result = self.fn(*self.args, **self.kwargs)
File "/var/task/example_app/main.py", line 29, in pong
import ptvsd; ptvsd.enable_attach(address=('0.0.0.0', 5858), redirect_output=True); ptvsd.wait_for_attach(); ptvsd.break_into_debugger()
File "/var/task/ptvsd/attach_server.py", line 101, in enable_attach
ptvsd_enable_attach(address)
File "/var/task/ptvsd/_remote.py", line 59, in enable_attach
daemon = install(pydevd,
File "/var/task/ptvsd/pydevd_hooks.py", line 128, in install
daemon = Daemon(**kwargs)
File "/var/task/ptvsd/daemon.py", line 503, in __init__
super(Daemon, self).__init__(wait_for_user, **kwargs)
File "/var/task/ptvsd/daemon.py", line 100, in __init__
self._install_exit_handlers()
File "/var/task/ptvsd/daemon.py", line 425, in _install_exit_handlers
self._exithandlers.install()
File "/var/task/ptvsd/exit_handlers.py", line 62, in install
self._install_signal_handler()
File "/var/task/ptvsd/exit_handlers.py", line 103, in _install_signal_handler
orig[sig] = signal.signal(sig, self._signal_handler)
File "/var/lang/lib/python3.8/signal.py", line 47, in signal
handler = _signal.signal(_enum_to_int(signalnum), _enum_to_int(handler))
ValueError: signal only works in main thread[INFO] 2020-08-22T21:47:23.107Z 19059eac-f60f-13d2-72c7-e958e53e642e Waiting for application shutdown.
[INFO] 2020-08-22T21:47:23.108Z 19059eac-f60f-13d2-72c7-e958e53e642e LifespanCycleState.SHUTDOWN: 'lifespan.shutdown.complete' event received from application.