Esempio n. 1
0
 def start(self):
     self.raft_thread = Thread(target=self.start_raft, args=())
     self.raft_thread.daemon = True
     self.raft_thread.start()
     self.monitor_thread = Thread(target=self.run_monitor, args=())
     # self.monitor_thread.daemon = True
     self.monitor_thread.start()
     pass
Esempio n. 2
0
 def start(self):
     """ Run the websocket in a thread """
     self._t = Thread(target=self._ws.run_forever)
     self._t.daemon = True
     self._t._running = True
     self._t.start()
     logger.info('Websocket thread started')
Esempio n. 3
0
 def start(self):
     """ Start Loaner.thread"""
     self._thread = Thread(target=self._run)
     self._thread.daemon = True
     self._running = True
     self._thread.start()
     logging.info(P('LOANER:') + C(' started'))
Esempio n. 4
0
    def start_book(self, pair, depth):
        """
		Starts the ticker subprocess
		"""
        self._tickerT = Thread(target=self.catch_book)
        self._tickerT.daemon = True
        self._tickerT.start()
        print('BOOK: catch_book thread started')
Esempio n. 5
0
 def start(self):
     #self.start_time = datetime.now()
     #self.populateTicker()
     self._t = Thread(target=self._ws.run_forever)
     self._t.daemon = True
     self._t._running = True
     self._t.start()
     logger.info('websocket started')
Esempio n. 6
0
    def start(self):
        self.t = Thread(target=self.ws.run_forever)

        self.t.daemon = True

        logger.debug('Starting websocket process.')

        self.t.start()

        logger.debug('Thread started.')
    def run(self):
        np = Thread(10)
        uid_list = ["904047861"] * 3
        result = []
        for uid in uid_list:
            res = np.apply_async(self.worker_genvent, (uid,))
            result.append(res)

        np.close()
        np.join()
    def main(self):
        """使用多线程执行程序"""
        np = Thread(10)
        uid_list = ["904047861"] * 3
        result = []
        for uid in uid_list:
            res = np.apply_async(self.run, (uid,))
            result.append(res)

        np.close()
        np.join()
Esempio n. 9
0
    def startTicker(self):
        """ Starts the 'tickcatcher' subprocess and 'tickCatcher' thread"""
        self._tickerP = Popen(["python", "tickcatcher.py"],
                              stdout=PIPE,
                              bufsize=1)
        print('TICKER: tickcatcher subprocess started')

        self._tickerT = Thread(target=self.tickCatcher)
        self._tickerT.daemon = True
        self._tickerT.start()
        print('TICKER: tickCatcher thread started')
Esempio n. 10
0
 def run_monitor(self):
     # while True:
     #     if not self.thread.is_alive() or common.raft_restart.wait(0):
     #         tools.logger.info('raft daemon restarting... ')
     #         self.restart()
     while True:
         print(self.raft_thread.getName(), self.raft_thread.is_alive())
         time.sleep(5)
         stop_thread(self.raft_thread)
         self.raft_thread = Thread(target=self.start_raft, args=())
         self.raft_thread.daemon = True
         self.raft_thread.start()
Esempio n. 11
0
 def start(self):
     """ Start the ticker """
     # print("Starting ticker")
     self._appProcess = Process(target=self._appRunner.run,
                                args=(TickPitcher, ))
     self._appProcess.daemon = True
     self._appProcess.start()
     self._running = True
     # print('TICKER: tickPitcher process started')
     self._tickThread = Thread(target=self.tickCatcher)
     self._tickThread.deamon = True
     self._tickThread.start()
Esempio n. 12
0
def kid(db):
    db.engine.dispose()
    connection_id = 0
    print('kid : connection_id:{}, status:{}'.format(connection_id,
                                                     db.engine.pool.status()))
    threadings = [Thread(target=work, args=(db, )) for i in range(2)]
    for thread in threadings:
        thread.start()
    for thread in threadings:
        thread.join()
    connection_id = db.engine.execute('select connection_id();').first()[0]
    print('kid : connection_id:{}, status:{}'.format(connection_id,
                                                     db.engine.pool.status()))
    time.sleep(2)
Esempio n. 13
0
    def start(self):
        self.t = Thread(target=self.ws.run_forever)

        self.t.daemon = True

        self.t.start()

        #print('Thread started')
        logger.debug('Thread started.')

        #slack_message = 'Ticker startup initialized.'
        slack_message = '\n*_Ticker startup initialized at ' + str(datetime.datetime.now()) + '._*\n\n'

        #slack_return = Ticker.send_slack_alert(self, channel_id=self.slack_channel_id_alerts, message=slack_message)
        slack_return = TickerGenerator.send_slack_alert(self, channel_id=self.slack_channel_id_alerts, message=slack_message)

        logger.debug('slack_return: ' + str(slack_return))
Esempio n. 14
0
    def build_house(cls):
        """
        Builds a Server Queue Manager(SQM) to control player and dealer turns.
        Assigns address to localhost with port 0 to ensure OS will assign an open port
        Authentication is key upon MetaClass initialization.
        Method returns SQM wrapped inside of a thread
        :return: Thread(target=BaseManager(address=('localhost', 0), authkey=cls.authkey), args=(),)
        """
        turn_queue = jQueue()

        class HouseManager(BaseManager):
            pass

        HouseManager.register('cards', callable=lambda: turn_queue)
        HouseManager.register('start_server', callable=lambda _: _.serve_forever())
        manager = HouseManager(address=('localhost', cls.port), authkey=MetaHouse.token)
        server = manager.get_server()
        setattr(cls, 'server', Thread(target=server.serve_forever, args=(), ))
        return
Esempio n. 15
0
    def startTicker(self):
        '''
        Starts ticker
        '''

        self.timeout = dt.now()

        script_dir = os.path.dirname(__file__)

        rel_path = "tickcatcher.py"
        abs_file_path = os.path.join(script_dir, rel_path)

        self._tickerP = Popen([sys.executable, abs_file_path],
                              stdout=PIPE,
                              bufsize=1)
        print('TICKER: tickcatcher subprocess started')

        self._tickerT = Thread(target=self.tickCatcher)
        self._tickerT.daemon = True
        self._tickerT.start()
        print('TICKER: tickCatcher thread started')
Esempio n. 16
0
def kid2():
    print('in kid2',os.getpid(),os.getppid())
    programs=[Thread(target=kid3),Process(target=kid3)]
    start(programs)
    time.sleep(100)
Esempio n. 17
0
def main():
    print('in main',os.getpid(),os.getppid())
    programs=[Thread(target=kid1)]
    start(programs)
    time.sleep(100)
Esempio n. 18
0
 def start(self):
     self.thread = Thread(target=self.auto_update)
     self.thread.daemon = True
     self.thread.start()
     logger.info('Updater started')
Esempio n. 19
0
 def start(self):
     self.t = Thread(target=self.ws.run_forever)
     self.t.daemon = True
     self.t.start()
     print('Thread started')
Esempio n. 20
0
 def start(self):
     self.thread = Thread(target=self._in_thread)
     self.thread.start()
Esempio n. 21
0
 def start(self):
     self._thread = Thread(target=self.run)
     self._thread.daemon = True
     self._thread.start()
     logger.info('Ticker started')
Esempio n. 22
0
    def __init__(self,
                 ns='',
                 twist=True,
                 pub_color=False,
                 back_led=False,
                 stabilize=True,
                 heading=False,
                 angular=False):
        super(MoveSphero, self).__init__()
        # self.ns = ns
        # self.publishers(ns = self.ns)
        self.namespaces = [
            '/sphero_rpg', '/sphero_ypp', '/sphero_www', '/sphero_wwb',
            '/sphero_rwp', '/sphero_rgo', '/sphero_pob', '/sphero_gbr'
        ]
        #make pool of workers
        self.pool_workers = Thread(4)

        self.twist = twist
        self.pub_color = pub_color
        self.back_led = back_led
        self.stabilize = stabilize
        self.heading = heading
        self.angular = angular
        self.def_queue_size = 5

        if self.twist == True:
            self.twist_rgo_pub = rospy.Publisher(
                '/sphero_rgo/cmd_vel', Twist, queue_size=self.def_queue_size)
            self.twist_ypp_pub = rospy.Publisher(
                '/sphero_ypp/cmd_vel', Twist, queue_size=self.def_queue_size)
            self.twist_pob_pub = rospy.Publisher(
                '/sphero_pob/cmd_vel', Twist, queue_size=self.def_queue_size)
            self.twist_www_pub = rospy.Publisher(
                '/sphero_www/cmd_vel', Twist, queue_size=self.def_queue_size)
            self.twist_rpg_pub = rospy.Publisher(
                '/sphero_rpg/cmd_vel', Twist, queue_size=self.def_queue_size)
            self.twist_rwp_pub = rospy.Publisher(
                '/sphero_rwg/cmd_vel', Twist, queue_size=self.def_queue_size)
            self.twist_wwb_pub = rospy.Publisher(
                '/sphero_wwb/cmd_vel', Twist, queue_size=self.def_queue_size)
            self.twist_gbr_pub = rospy.Publisher(
                '/sphero_gbr/cmd_vel', Twist, queue_size=self.def_queue_size)

        if self.pub_color:
            self.color_rgo_pub = rospy.Publisher(
                '/sphero_rgo/set_color',
                ColorRGBA,
                queue_size=self.def_queue_size)
            self.color_ypp_pub = rospy.Publisher(
                '/sphero_ypp/set_color',
                ColorRGBA,
                queue_size=self.def_queue_size)
            self.color_pob_pub = rospy.Publisher(
                '/sphero_pob/set_color',
                ColorRGBA,
                queue_size=self.def_queue_size)
            self.color_www_pub = rospy.Publisher(
                '/sphero_www/set_color',
                ColorRGBA,
                queue_size=self.def_queue_size)
            self.color_rpg_pub = rospy.Publisher(
                '/sphero_rpg/set_color',
                ColorRGBA,
                queue_size=self.def_queue_size)
            self.color_rwg_pub = rospy.Publisher(
                '/sphero_rwg/set_color',
                ColorRGBA,
                queue_size=self.def_queue_size)
            self.color_wwb_pub = rospy.Publisher(
                '/sphero_wwb/set_color',
                ColorRGBA,
                queue_size=self.def_queue_size)
            self.color_gbr_pub = rospy.Publisher(
                '/sphero_gbr/set_color',
                ColorRGBA,
                queue_size=self.def_queue_size)

        if self.back_led:
            self.back_rgo_pub = rospy.Publisher('/sphero_rgo/set_back_led',
                                                Float32,
                                                queue_size=self.def_queue_size)
            self.back_ypp_pub = rospy.Publisher('/sphero_ypp/set_back_led',
                                                Float32,
                                                queue_size=self.def_queue_size)
            self.back_pob_pub = rospy.Publisher('/sphero_pob/set_back_led',
                                                Float32,
                                                queue_size=self.def_queue_size)
            self.back_www_pub = rospy.Publisher('/sphero_www/set_back_led',
                                                Float32,
                                                queue_size=self.def_queue_size)
            self.back_rpg_pub = rospy.Publisher('/sphero_rpg/set_back_led',
                                                Float32,
                                                queue_size=self.def_queue_size)
            self.back_rwg_pub = rospy.Publisher('/sphero_rwg/set_back_led',
                                                Float32,
                                                queue_size=self.def_queue_size)
            self.back_wwb_pub = rospy.Publisher('/sphero_wwb/set_back_led',
                                                Float32,
                                                queue_size=self.def_queue_size)
            self.back_gbr_pub = rospy.Publisher('/sphero_gbr/set_back_led',
                                                Float32,
                                                queue_size=self.def_queue_size)

        if self.stabilize:
            self.stab_rgo_pub = rospy.Publisher(
                '/sphero_rgo/disable_stabilization',
                Bool,
                queue_size=self.def_queue_size)
            self.stab_ypp_pub = rospy.Publisher(
                '/sphero_ypp/disable_stabilization',
                Bool,
                queue_size=self.def_queue_size)
            self.stab_pob_pub = rospy.Publisher(
                '/sphero_pob/disable_stabilization',
                Bool,
                queue_size=self.def_queue_size)
            self.stab_www_pub = rospy.Publisher(
                '/sphero_www/disable_stabilization',
                Bool,
                queue_size=self.def_queue_size)
            self.stab_rpg_pub = rospy.Publisher(
                '/sphero_rpg/disable_stabilization',
                Bool,
                queue_size=self.def_queue_size)
            self.stab_rwg_pub = rospy.Publisher(
                '/sphero_rwg/disable_stabilization',
                Bool,
                queue_size=self.def_queue_size)
            self.stab_wwb_pub = rospy.Publisher(
                '/sphero_wwb/disable_stabilization',
                Bool,
                queue_size=self.def_queue_size)
            self.stab_gbr_pub = rospy.Publisher(
                '/sphero_gbr/disable_stabilization',
                Bool,
                queue_size=self.def_queue_size)

        if self.heading:
            self.head_rgo_pub = rospy.Publisher('/sphero_rgo/set_heading',
                                                Float32,
                                                queue_size=self.def_queue_size)
            self.head_ypp_pub = rospy.Publisher('/sphero_ypp/set_heading',
                                                Float32,
                                                queue_size=self.def_queue_size)
            self.head_pob_pub = rospy.Publisher('/sphero_pob/set_heading',
                                                Float32,
                                                queue_size=self.def_queue_size)
            self.head_www_pub = rospy.Publisher('/sphero_www/set_heading',
                                                Float32,
                                                queue_size=self.def_queue_size)
            self.head_rpg_pub = rospy.Publisher('/sphero_rpg/set_heading',
                                                Float32,
                                                queue_size=self.def_queue_size)
            self.head_rwg_pub = rospy.Publisher('/sphero_rwg/set_heading',
                                                Float32,
                                                queue_size=self.def_queue_size)
            self.head_wwb_pub = rospy.Publisher('/sphero_wwb/set_heading',
                                                Float32,
                                                queue_size=self.def_queue_size)
            self.head_gbr_pub = rospy.Publisher('/sphero_gbr/set_heading',
                                                Float32,
                                                queue_size=self.def_queue_size)

        if self.angular:
            self.angvel_rgo_pub = rospy.Publisher(
                '/sphero_rgo/set_angular_velocity',
                Float32,
                queue_size=self.def_queue_size)
            self.angvel_ypp_pub = rospy.Publisher(
                '/sphero_ypp/set_angular_velocity',
                Float32,
                queue_size=self.def_queue_size)
            self.angvel_pob_pub = rospy.Publisher(
                '/sphero_pob/set_angular_velocity',
                Float32,
                queue_size=self.def_queue_size)
            self.angvel_www_pub = rospy.Publisher(
                '/sphero_www/set_angular_velocity',
                Float32,
                queue_size=self.def_queue_size)
            self.angvel_rpg_pub = rospy.Publisher(
                '/sphero_rpg/set_angular_velocity',
                Float32,
                queue_size=self.def_queue_size)
            self.angvel_rwg_pub = rospy.Publisher(
                '/sphero_rwg/set_angular_velocity',
                Float32,
                queue_size=self.def_queue_size)
            self.angvel_wwb_pub = rospy.Publisher(
                '/sphero_wwb/set_angular_velocity',
                Float32,
                queue_size=self.def_queue_size)
            self.angvel_gbr_pub = rospy.Publisher(
                '/sphero_gbr/set_angular_velocity',
                Float32,
                queue_size=self.def_queue_size)