1
Fork 0
mirror of https://github.com/pds-nest/nest.git synced 2024-11-22 13:04:19 +00:00

Now with Thread magic

This commit is contained in:
Lorenzo Balugani 2021-05-28 14:07:26 +02:00
parent 37ef4a40f4
commit 6e682309d4
3 changed files with 11 additions and 1 deletions

0
nest_backend/routes.py Normal file
View file

View file

@ -5,8 +5,16 @@ from nest_backend.gestione import *
import datetime import datetime
from flask_cors import cross_origin from flask_cors import cross_origin
from nest_backend.errors import * from nest_backend.errors import *
import nest_backend.app
from nest_crawler.repo_search import search_repo_conditions 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() @cross_origin()
@jwt_required() @jwt_required()
@ -107,7 +115,8 @@ def page_repositories():
repository.start = datetime.datetime.now() repository.start = datetime.datetime.now()
ext.session.commit() ext.session.commit()
try: try:
search_repo_conditions(repository.id) thread = threading.Thread(target=tweet_importer, args=(repository.id,))
thread.start()
except Exception: except Exception:
return json_success(repository.to_json()), 201 return json_success(repository.to_json()), 201
return json_success(repository.to_json()), 201 return json_success(repository.to_json()), 201

View file

@ -4,6 +4,7 @@ from datetime import datetime, timedelta
import tweepy as tw import tweepy as tw
from nest_crawler.associate_condition_tweet import associate_condition_tweet from nest_crawler.associate_condition_tweet import associate_condition_tweet
def search_repo_conditions(repository_id): def search_repo_conditions(repository_id):
api = authentication.authenticate() api = authentication.authenticate()