i have two queues in kombu; one to submit requests (to do something) and another that spits out via pub/sub the incremental status of said request. therefore in my process it will publish to the request queue and consume on the response queue. as the task may take some time, i want to provide the user with feedback as to what is happening in the backend; it all works on the command line, as my kombu consume
callback allows me to, say, add a logging.info()
statement to spit back information to my user:
def callback( msg, env ):
logging.info( str(msg) )
consumer.register_callback( callback )
consumer.consume()
while continue_consuming:
connection.drain_events()
however, i now want to be able to provide the same functionality in django. i understand that i can create a generator
function as the input to a HttpResponse
object:
def view( reqeust ):
HttpResponse( gen() )
def gen():
yield 'streaming... '
but i cannot conceptualize how i could implement the message callback of the kombu queue into a generator to provide this... any ideas?
i want to avoid having to use a database layer to store the progress/results if possible.