-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgen.py
More file actions
52 lines (48 loc) · 1.29 KB
/
Copy pathgen.py
File metadata and controls
52 lines (48 loc) · 1.29 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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# -*- coding: utf-8 -*-
#
# Author: jimin.huang
#
# Created Time: 2015年05月15日 星期五 20时26分21秒
#
import tornado.httpclient
import tornado.gen
import urllib
import logging
import database
def async(func):
def wrapper(*args, **kwargs):
yield func(*args, **kwargs)
return wrapper
@async
def search(search_id):
data = {'search_id':search_id}
body = urllib.urlencode(data)
response =\
tornado.httpclient.HTTPClient().fetch(
"http://scheduler:9000/service/searchEngine/search",
method='POST',
body=body,
)
logging.info('Search response: {response}'.format(response=response.body))
if response.body == 'Success':
return True
else:
return False
@async
def calculate(user_id):
user = database.User.select(user_id)
if user is None:
return
data = {'model_id': user.user_model, 'user_id':user_id}
body = urllib.urlencode(data)
response =\
tornado.httpclient.HTTPClient().fetch(
"http://scheduler:9000/service/model/calculate",
method='POST',
body=body,
)
logging.info('Calculate response: {response}'.format(response=response.body))
if response.body == 'Success':
return True
else:
return False