Python2.7 Response To Client First Then Process (shopify Webhook)
I am building a webhook to connect Shopify with my dispatch. Shopify Webhook sends a json request and wait for 5 seconds, if it doesn't receive 200 back, it terminate the request and try another one.
My server at the moment handle this straightaway
- receive a shopify request
- sorting order data from shopify
- send request to dispatch server
- check response from the server
- response to shopify
with this sometimes it takes slightly longer than 5 seconds, so shopify send requests again while the server is updating the dispatch.
What's the best solution to fix this?
I am thinking two solutions
a. Response 200 back to shopify first then process dispatch (I am not sure how to do this with python2.7) b. Create a database to store shopify request, so shopify request just create an order record then it will receive 200 back (which should take less than 5 seconds). With this set up crontask or celery task to update dispatch
Better to use task queues. Use celery to do time taking tasks in background. As soon as you get the response from shopify, give your task to celery so that it can run the tasks in background, then you can send the 200 response back.
- → I can't convert Json to string [OctoberCms]
- → Uncaught TypeError Illegal invocation when send FormData to ajax
- → Laravel Send URL with JSON
- → how to write react component to construct HTML DOM
- → AJAX folder path issue
- → Chaining "Count of Columns" of a Method to Single Query Builder
- → Laravel - bindings file for repositories
- → Good solution to work with rest-api like SPA with redux?
- → getting the correct record in Angular with a json feed and passed data
- → Transformer usage on laravel/dingo API
- → Ember.js JSON API confusion
- → How can I query Firebase for an equalTo boolean parameter?