Make the worker post json. Add a retry timeout after an incompletel queue item is processed. Submit webhook jobs to the queue on a successful push.

This commit is contained in:
yackob03 2013-11-16 15:05:26 -05:00
parent f55e4074e0
commit e787d8b2d8
4 changed files with 31 additions and 4 deletions

View file

@ -2,6 +2,7 @@ import logging
import daemon
import argparse
import requests
import json
from data.queue import webhook_queue
from workers.worker import Worker
@ -20,9 +21,10 @@ class WebhookWorker(Worker):
def process_queue_item(self, job_details):
url = job_details['url']
payload = job_details['payload']
headers = {'Content-type': 'application/json'}
try:
resp = requests.post(url, data=payload)
resp = requests.post(url, data=json.dumps(payload), headers=headers)
if resp.status_code/100 != 2:
logger.error('%s response for webhook to url: %s' % (resp.status_code,
url))