Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Tree: 97e0a157a5
Fetching contributors…

Cannot retrieve contributors at this time

29 lines (23 sloc) 0.833 kB
from django.utils.decorators import available_attrs
from functools import wraps
import logging
def task():
from django_ztask.conf import settings
import zmq
def wrapper(func):
function_name = '%s.%s' % (func.__module__, func.__name__)
logger = logging.getLogger('ztaskd')
logger.info('Registered task: %s' % function_name)
context = zmq.Context()
socket = context.socket(zmq.DOWNSTREAM)
socket.connect(settings.ZTASKD_URL)
@wraps(func)
def _func(*args, **kwargs):
try:
socket.send_pyobj((function_name, args, kwargs))
except Exception, e:
func(*args, **kwargs)
setattr(func, 'async', _func)
setattr(func, 'delay', _func)
return func
return wrapper
Jump to Line
Something went wrong with that request. Please try again.