forked from douban/pymesos
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexecutor.py
More file actions
executable file
·38 lines (29 loc) · 1.05 KB
/
Copy pathexecutor.py
File metadata and controls
executable file
·38 lines (29 loc) · 1.05 KB
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
37
38
#!/usr/bin/env python2.7
from __future__ import print_function
import sys
import time
from threading import Thread
from pymesos import MesosExecutorDriver, Executor, decode_data
from addict import Dict
class MinimalExecutor(Executor):
def launchTask(self, driver, task):
def run_task(task):
update = Dict()
update.task_id.value = task.task_id.value
update.state = 'TASK_RUNNING'
update.timestamp = time.time()
driver.sendStatusUpdate(update)
print(decode_data(task.data), file=sys.stderr)
time.sleep(30)
update = Dict()
update.task_id.value = task.task_id.value
update.state = 'TASK_FINISHED'
update.timestamp = time.time()
driver.sendStatusUpdate(update)
thread = Thread(target=run_task, args=(task,))
thread.start()
if __name__ == '__main__':
import logging
logging.basicConfig(level=logging.DEBUG)
driver = MesosExecutorDriver(MinimalExecutor(), use_addict=True)
driver.run()