-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathtask_worker.py
More file actions
37 lines (30 loc) · 931 Bytes
/
task_worker.py
File metadata and controls
37 lines (30 loc) · 931 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# coding=utf-8
"""
beanstalkd Job分布式处理
:copyright: (c) 2015 by fangpeng.
:license: MIT, see LICENSE for more details.
"""
__author__ = 'fang'
import os
import json
import sys
sys.path.insert(0, os.path.join(os.path.dirname(__file__), "../"))
import job
class TalkWorker(job.JobService):
def process(self, job):
if not job:
return
data = json.loads(job.body)
if isinstance(data, dict) and "cmd" in data:
cmd = data['cmd']
if cmd == 'yourCmd' and 'args' in data:
args = data['args']
# apply(func, (arg1, arg2,...argn))
#
# if cmd == 'yourCmd2' and 'args' in data:
# args = data['args']
# # apply(func, (arg1, arg2,...argn))
# ............
if __name__ == '__main__':
worker = TalkWorker('127.0.0.1', 11300, 'taskWorkers')
worker.start()