zappa / Zappa

Serverless Python
https://zappa.ws/zappa
MIT License
3.31k stars 363 forks source link

[Migrated] Zappa async task results in 403 Bad Request from Cloudfront #784

Closed jneves closed 6 months ago

jneves commented 3 years ago

Originally from: https://github.com/Miserlou/Zappa/issues/1929 by prateekponnuru

I am trying to use aysnc tasks for the first time in my django project and when i access the API that invokes the async task, i get the 403 Bad Request error from Cloudfront.

Code

###task.py
from django.core.mail import send_mail
@task
def send_mail_async(email_id):
    start = datetime.now()
    sleep(120)
    body = """zappa task started at {}
              waited for 100.
              mail sent at: {}""".format(str(start), str(datetime.now()))
    send_mail("Email using Zappa Task", body, settings.EMAIL_HOST_USER, [email_id])

####views.py
from task.py import send_mail_async
class zappa_task(APIView):
    def get(self, request, version):
        email = request.GET.get('email')
        t = datetime.now()
        send_mail_async(email)

        return httpResponse('Zappa task triggered at: {}, code returned at: {}'.format(str(t), str(datetime.now())))
###

My Environment

github-actions[bot] commented 7 months ago

Hi there! Unfortunately, this Issue has not seen any activity for at least 90 days. If the Issue is still relevant to the latest version of Zappa, please comment within the next 10 days if you wish to keep it open. Otherwise, it will be automatically closed.

github-actions[bot] commented 6 months ago

Hi there! Unfortunately, this Issue was automatically closed as it had not seen any activity in at least 100 days. If the Issue is still relevant to the latest version of Zappa, please open a new Issue.