--
You received this message because you are subscribed to the Google Groups "pylons-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pylons-discus...@googlegroups.com.
To post to this group, send email to pylons-...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/pylons-discuss/25d30da3-5079-46f7-b15a-2ffe3d44c06e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
@view_config( … )def some_view(request): # Do some view stuff, modify db objects, etc.
# Local helper function that issues the message to the broker. This # function has access to the closure but beware that db objects are # committed and invalid! def _send_message(success, *args, **kwargs): if success:
# Send message to the broker, thus spawning a worker task. dramatiq_actors.some_task.send(*args) # Or Celery tasks, whatever.
# Get the transaction for this request. t = request.tm.get()
# Arguments for the task. args = ( foo, 3, )
kwargs = {}
# Add the after-commit hook, i.e. call _send_message() when the
# request's transaction has committed. t.addAfterCommitHook(_send_message, args=args, kws=kwargs)
# And return from the view function.
return {
"some": "results",
}--
You received this message because you are subscribed to the Google Groups "pylons-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pylons-discuss+unsubscribe@googlegroups.com.
To post to this group, send email to pylons-discuss@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/pylons-discuss/ef6bf67d-acec-4dae-b318-7749743add31%40googlegroups.com.