Commit 8d801fe6 authored by Marco Mariani's avatar Marco Mariani

queue multiple callbacks

parent 24a50d1d
from datetime import datetime from datetime import datetime
import csv import csv
import feedparser import feedparser
import io
import socket import socket
import json import json
import time import time
...@@ -82,16 +83,16 @@ def notify(): ...@@ -82,16 +83,16 @@ def notify():
except AttributeError: except AttributeError:
abort(httplib.BAD_REQUEST) abort(httplib.BAD_REQUEST)
with open(callback_filepath, 'r') as callback_file:
callback = callback_file.read()
abort_it = False
for callback in io.open(callback_filepath, 'r', encoding='utf8'):
timestamp = int(math.floor(time.mktime(feed.feed.updated_parsed))) timestamp = int(math.floor(time.mktime(feed.feed.updated_parsed)))
equeue_request = json.dumps(dict( equeue_request = json.dumps({
command=callback, 'command': callback,
timestamp=timestamp, 'timestamp': timestamp,
)) })
equeue_socket = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) equeue_socket = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
equeue_socket.connect(app.config['EQUEUE_SOCKET']) equeue_socket.connect(app.config['EQUEUE_SOCKET'])
...@@ -100,6 +101,10 @@ def notify(): ...@@ -100,6 +101,10 @@ def notify():
equeue_socket.close() equeue_socket.close()
if result != callback: if result != callback:
abort_it = True
if abort_it:
# XXX if possible, communicate info about the failed callbacks
abort(httplib.INTERNAL_SERVER_ERROR) abort(httplib.INTERNAL_SERVER_ERROR)
return '', httplib.NO_CONTENT return '', httplib.NO_CONTENT
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment