Esempio n. 1
0
    def __init__ (self, pusher_stream="pox"):
        core.addListeners(self)
        core.openflow.addListeners(self)
        self.stream = pusher_stream

        self.stopStatsThread = Event()
        self.syncThread = TimerThread(self.stopStatsThread, request_stats, STAT_SAMPLING_PERIOD)
        self.syncThread.start()
Esempio n. 2
0
 def new_game(self):
     self.timer_thread.stop_thread()
     self.timer_text.set("time: 00:00")
     self.round_number = 0
     self.guess_history = []
     self.l.delete(0, END)
     self.answer_number = self.create_number()
     del self.timer_thread
     self.timer_thread = TimerThread(self.update_time)
     self.timer_thread.start()
     self.input_number.set('')
Esempio n. 3
0
 def __init__(self):
     self.answer_number = self.create_number()
     # 開始Timer thread 物件
     self.timer_thread = TimerThread(self.update_time)
     self.current_second = 0
     self.input_number = StringVar()
Esempio n. 4
0
 def schedule_timer(self, plug, time):
     stop_event = Event()
     TimerThread(stop_event, time, plug).start()
     self.timer_events.append(stop_event)
Esempio n. 5
0
monkey.patch_all()
import logging
import os
from flask import Flask, jsonify, request
from raft.cluster import Cluster
from timer_thread import TimerThread

logging.basicConfig(format='%(asctime)s - %(levelname)s: %(message)s',
                    datefmt='%H:%M:%S',
                    level=logging.INFO)

NODE_ID = int(os.environ.get('NODE_ID'))
cluster = Cluster()
node = cluster[NODE_ID]
timer_thread = TimerThread(NODE_ID)


def create_app():
    raft = Flask(__name__)
    timer_thread.start()
    return raft


app = create_app()


@app.route('/raft/vote', methods=['POST'])
def request_vote():
    vote_request = request.get_json()
    result = timer_thread.vote(json.loads(vote_request))
Esempio n. 6
0
 def timer(self, timer):
     timer_thread = TimerThread(timer)
     timer_thread.start()