Might I be on the right track? Finally ?

This commit is contained in:
Julien Lengrand-Lambert
2013-02-15 00:32:18 +01:00
parent 949d5979c0
commit 470a56e911
3 changed files with 65 additions and 1 deletions

29
tests/flask_stop.py Normal file
View File

@@ -0,0 +1,29 @@
import time
from multiprocessing import Process
from flask import Flask
app = Flask(__name__)
@app.route('/')
def index():
return "Hi there!!!"
def run():
app.run()
if __name__ == '__main__':
app.debug = True
print "starting process"
server = Process(target=run)
server.start()
print "sleeping"
time.sleep(5)
print "ending process"
server.terminate()
server.join()
print "bye..."

View File

@@ -10,6 +10,12 @@ from datamodel import TrendyHashtag
from datamodel import Tweet
from datamodel import Member
from streamer import HashtagLogger
import signal
import sys
def connect():
"""
@@ -58,5 +64,24 @@ def add_hashtag():
def index():
return render_template('statistics.html')
class Twiderboard():
def __init__(self):
# registering the signal to stop command line
signal.signal(signal.SIGINT, self.stop_handler)
print "Starting streamer"
self.h = HashtagLogger(data.engine_url, oauth=data.oauth)
self.h.start()
app.run()
def stop_handler(self, signal, frame):
print "Stopping Streamer"
self.h.stop()
print "Stopping Command Line"
sys.exit(0)
if __name__ == '__main__':
app.run()
Twiderboard()

View File

@@ -0,0 +1,10 @@
"""
Top level application that will start the streamer and the API.
"""
from flask_app import app
class Twiderboard():
def __init__(self):
app.run()
print "coucou"