Skip to content

Instantly share code, notes, and snippets.

@jMyles
Last active August 29, 2015 14:15
Show Gist options
  • Save jMyles/00d41ff4c304c3135035 to your computer and use it in GitHub Desktop.
Save jMyles/00d41ff4c304c3135035 to your computer and use it in GitHub Desktop.
from hendrix.contrib.async import do_async
def my_view(request):
# blah blah blah, Django stuff
@do_async.after_response(pubsub_id):
def function_name_that_becomes_thread_name(reporter):
for long_thing in long_things:
result_of_long_thing = long_thing()
if result_of_long_thing.is_important():
reporter.publish(result_of_long_thing)
# blah blah blah, more Django stuff (executed immediately)
return HttpResponse(blah) # Only after this response is sent back to the client will the function on line 9 be run
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment