async def index():
# Make HTTP request behind the scene
resp = requests.get('update_counter_endpoint')
return {'hello': 'world'}
It will be great chalice support async function. This way I can execute non blocking function.
Could you explain a little bit more about what you're expecting here? I'm not sure async makes sense for a response handler.
When I'm Building Messenger Bot one of the key thing I need to do is respond to the webhook within 20 seconds. Ref: Webhook. Failing to do that my webhook will be Disabled.
def webhook():
# I need to perform this task later. This will take more than 20 sec to complete.
# So I thought async will be the best for this scenario
my_code_take_more_than_20_seconds()
# But I need to send 200 within 20 seconds window.
return '200 Ok'
The lambda runtime will freeze any execution once you send a response, so it's not possible for us to implement a feature like this. Ideally, I think the workflow for these kinds of webhook handlers would be to throw the work into an SQS queue and have another lambda handler to process the queued work.
Thanks for your response. Definitely I'll look into SQS.
Hiya, I develop quite a lot using async/await in Python3.7. It's very nice being able to request multiple remote requests (function -> weather, stocks, twitter) at once and then process the results together later on. I am very much on board with helping as much as I can to allow async support (supported by AWS Lambda Python Runtime) to work well with chalice... go and node.js serverless frameworks have made a point to make this work as well.. however both go and node.js are async prioritized in general.
Could this be done using chalice?
https://docs.aws.amazon.com/apigateway/latest/developerguide/set-up-lambda-integration-async.html
AWS Lambda Async Events are not Async HTTP user or API requests. They are
Async requests from AWS services like S3 and SNS. Not to be confused with
Async HTTP socket handling.
On Fri, Jun 7, 2019 at 3:54 PM Islam notifications@github.com wrote:
Could this be done using chalice?
https://docs.aws.amazon.com/apigateway/latest/developerguide/set-up-lambda-integration-async.html
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/aws/chalice/issues/637?email_source=notifications&email_token=AACKRFL2MBXH3B65EUGJ6PLPZLYK7A5CNFSM4EID7VL2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODXHIDMQ#issuecomment-500072882,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AACKRFNVOOVHSYKY7HLWZCTPZLYK7ANCNFSM4EID7VLQ
.>
[image: --]
Shane R. Spencer
[image: https://]about.me/ShaneSpencer
https://about.me/ShaneSpencer?promo=email_sig
Similarly I am using Chalice for an application that needs to respond to webhook requests within 3 seconds. At the moment I'm not doing anything particularly complex, so I can perform operations within the 3 second window, but in the future I would like to start doing some more complex calculations to decouple processing from the webhook callback.
Has anyone found an elegant solution to this using Chalice? SQS seems like the easiest method to setup, but with an empty queue, you're looking at 250,000 requests per month with long-polling setup - still within the free tier budget, but it seems silly to me to have an architecture that involves polling when webhooks were designed to avoid applications having to use polling.
When I'm Building Messenger Bot one of the key thing I need to do is respond to the webhook within 20 seconds. Ref: Webhook. Failing to do that my webhook will be Disabled.
def webhook(): # I need to perform this task later. This will take more than 20 sec to complete. # So I thought async will be the best for this scenario my_code_take_more_than_20_seconds() # But I need to send 200 within 20 seconds window. return '200 Ok'
Most helpful comment
Hiya, I develop quite a lot using async/await in Python3.7. It's very nice being able to request multiple remote requests (function -> weather, stocks, twitter) at once and then process the results together later on. I am very much on board with helping as much as I can to allow async support (supported by AWS Lambda Python Runtime) to work well with chalice... go and node.js serverless frameworks have made a point to make this work as well.. however both go and node.js are async prioritized in general.