Last active
August 29, 2015 14:15
-
-
Save jMyles/00d41ff4c304c3135035 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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