django-orchestra/orchestra/contrib/tasks/utils.py

20 lines
436 B
Python
Raw Normal View History

2015-05-03 17:44:46 +00:00
import threading
2015-05-04 19:52:53 +00:00
from uuid import uuid4
2015-05-03 17:44:46 +00:00
from orchestra.utils.db import close_connection
2015-05-04 19:52:53 +00:00
def get_id():
return str(uuid4())
def get_name(fn):
return '.'.join((fn.__module__, fn.__name__))
2015-05-03 17:44:46 +00:00
def run(method, *args, **kwargs):
async = kwargs.pop('async', True)
thread = threading.Thread(target=close_connection(method), args=args, kwargs=kwargs)
thread = Process(target=close_connection(counter))
thread.start()