mirror of
https://github.com/pds-nest/nest.git
synced 2024-11-21 20:44:18 +00:00
Now with Thread magic
This commit is contained in:
parent
37ef4a40f4
commit
6e682309d4
3 changed files with 11 additions and 1 deletions
0
nest_backend/routes.py
Normal file
0
nest_backend/routes.py
Normal file
|
@ -5,8 +5,16 @@ from nest_backend.gestione import *
|
|||
import datetime
|
||||
from flask_cors import cross_origin
|
||||
from nest_backend.errors import *
|
||||
import nest_backend.app
|
||||
from nest_crawler.repo_search import search_repo_conditions
|
||||
|
||||
import threading
|
||||
|
||||
|
||||
def tweet_importer(rid):
|
||||
with nest_backend.app.app.app_context():
|
||||
search_repo_conditions(rid)
|
||||
|
||||
|
||||
@cross_origin()
|
||||
@jwt_required()
|
||||
|
@ -107,7 +115,8 @@ def page_repositories():
|
|||
repository.start = datetime.datetime.now()
|
||||
ext.session.commit()
|
||||
try:
|
||||
search_repo_conditions(repository.id)
|
||||
thread = threading.Thread(target=tweet_importer, args=(repository.id,))
|
||||
thread.start()
|
||||
except Exception:
|
||||
return json_success(repository.to_json()), 201
|
||||
return json_success(repository.to_json()), 201
|
||||
|
|
|
@ -4,6 +4,7 @@ from datetime import datetime, timedelta
|
|||
import tweepy as tw
|
||||
from nest_crawler.associate_condition_tweet import associate_condition_tweet
|
||||
|
||||
|
||||
def search_repo_conditions(repository_id):
|
||||
|
||||
api = authentication.authenticate()
|
||||
|
|
Loading…
Reference in a new issue