My GAE 애플리케이션은 webapp2를 사용하여 Python으로 작성되었습니다. 내 응용 프로그램은 사용자의 온라인 소셜 네트워크를 분석하는 것을 목표로합니다. 사용자는 내 애플리케이션에 로그인하고 권한을 부여 할 수 있으므로 데이터를 더 크롤링하기 위해 액세스 토큰이 저장됩니다. 그런 다음 작업 대기열을 사용하여 크롤링 프로세스가 시간 소모적이므로 백엔드 작업을 시작합니다. 그러나 액세스 토큰을 가져 오려면 데이터 저장소에 액세스 할 때 얻을 수 있습니다. 작업 대기열의 임시 저장소 대신 프론트 엔드의 데이터에 액세스하는 방법이 있는지 궁금합니다.GAE 작업 대기열 애플리케이션 저장소
사용자
class Callback(webapp2.RequestHandler):
def get(self):
global client
global r
code = self.request.get('code')
try:
client = APIClient(app_key=APP_KEY, app_secret=APP_SECRET,redirect_uri=CALLBACK_URL)
r = client.request_access_token(code)
access_token = r.access_token
record = model.getAccessTokenByUid(r.uid)
if record is None or r.access_token != record.accessToken:
# logging.debug("access token stored")
**model.insertAccessToken(long(r.uid), access_token, r.expires_in, "uncrawled", datetime.datetime.now())** #data stored here
session = self.request.environ['beaker.session']
session['uid'] = long(r.uid)
self.redirect(CLUSTER_PAGE % ("true"))
except Exception, e:
logging.error("callback:%s" % (str(e)));
self.redirect(CLUSTER_PAGE % ("false"))
class CrawlWorker(webapp2.RequestHandler):
def post(self): # should run at most 1/s
uid = self.request.get('uid')
logging.debug("start crawling uid:%s in the backend" % (str(uid)))
global client
global client1
global r
tokenTuple = model.getAccessTokenByUid(uid)
if tokenTuple is None: **#here i always get a None**
logging.error("CounterWorker:oops, authorization token is missed.")
return
"할 수 없습니까?" "액세스 토큰을 가져 오기 위해 데이터 스토어에 액세스하면 얻을 수 있습니다." – Greg
작업을 어디에서 작성하고 있습니까? 'uid' 매개 변수가 있는지 확인 하시겠습니까? 'CrawlWorker'에있는'debug' 호출의 결과는 무엇입니까? –