Esempio n. 1
0
def get_date(id):
    thread.allowsuspend(True)
    global debug_date
    global datebase
    global namelist
    global internet_date
    global display_index
    global start_flag
    baseurl_1 = "http://fundgz.1234567.com.cn/js/"
    baseurl_2 = ".js?rt=1463558676006"
    while True:
        if start_flag == 1:
            utime.sleep(5)
            debug_date.append('start get date')
            url = baseurl_1 + datebase["info"][
                namelist[display_index]] + baseurl_2
            try:
                temp = urequests.get(url).text
                d = ujson.loads(temp[temp.find("(") + 1:temp.find(")")])
                internet_date[namelist[display_index]] = d
                del temp
            except:
                internet_date[namelist[display_index]] = None
            debug_date.append('finish')
            thread.notify(id, 1001)
            gc.collect()
Esempio n. 2
0
	def run(self, sync = False):
		self.syncMode = sync
		self.running = True

		thread.notify(self.thread, 1)
		
		return self.wait()
Esempio n. 3
0
def handleSoundThread(song):
    """ stopps running sound thread and starts a new thread with value saved in 'song'
    song: (String) name of the song to start
    """
    global sound_thread

    _thread.notify(sound_thread, _thread.EXIT)
    utime.sleep_ms(wait_before_start_thread)
    sound_thread = _thread.start_new_thread("song", songs.find_song, (song,))
Esempio n. 4
0
 def publish(self, topic, message):
     if topic in self.subscriptions:
         for thread in self.subscriptions[topic]:
             _thread.notify(thread, _thread.RESUME) # Resume the task
             _thread.sendmsg(thread, json.dumps({"topic": topic, "message": message})) # Encode topic and message
     
     # Publish every message to the wildcard topic
     if "*" in self.subscriptions:
         for thread in self.subscriptions["*"]:
             _thread.notify(thread, _thread.RESUME) # Resume the task
             _thread.sendmsg(thread, json.dumps({"topic": topic, "message": message})) # Encode topic and message
Esempio n. 5
0
def handleAnimations(animation_name=None):
    """ stopps running animation thread and creates a new thread.
    If animation_name is given, it creates a thread with animations.start(animation_name)
    if animation_name == None it creates a thread with animations.next()
    animation_name: (String) name of the animation to start
    """
    global animation_thread
    _thread.notify(0, _thread.EXIT)

    if animation_name == None:
        utime.sleep_ms(50)
        animation_thread = _thread.start_new_thread("animation", animations.next, () )
    else:
        print("starting animation {}".format(animation_name))
        utime.sleep_ms(wait_before_start_thread)
        animation_thread = _thread.start_new_thread("animation", animations.start, (animation_name,))
Esempio n. 6
0
    def MainThread(self):
        # основной цикл
        if self.isDataFromServer:
            # есть данные от сервера
            self._analis_server_socket_buff_(self.datafromserver)
            self.isDataFromServer = False
            if (self.idThrReciveSocket != None):
                _thread.notify(self.idThrReciveSocket, SEND_DATA_TO_SERVER)
            if (self.err_thr_read != ERR_NONE):
                self.err_thr_read == ERR_NONE
                _thread.notify(self.idThrReciveSocket, READ_DATA_FROM_SERVER)

        if self.evConnectGsm == True:
            # Пробуем подключиться
            self.evConnectGsm = False
            if (self.isConnect() == False):
                print("Probuem podkluchitsya")
                self.ConnectToGSM()
Esempio n. 7
0
def test():
i = 0
while i<10:
i=i+1
print("Hello from thread")
print(_thread.getSelfName())
mainID = _thread.getReplID()
print(mainID)
print(_thread.getmsg())
print(_thread.wait())

while _thread.wait() :
#_thread.sendmsg(mainID, i)


time.sleep(2)


thrID = _thread.start_new_thread("test",test,())
_thread.sendmsg(thrID, 5)
_thread.getmsg()
_thread.list()
_thread.notify(thrID, 1)




#k=_thread.start_new_thread("testThr",testThread,(1,))


_thread.start_new_thread(testThread())

k=0
while k<15:
    k=k+1
    time.sleep(1)
    print("Hello from main")
    pass
Esempio n. 8
0
 def Stop(self):
     if self._started:
         self._server.close()
         if self.isThreaded:
             _ = _thread.notify(self.thID, _thread.EXIT)
Esempio n. 9
0
 def Stop(self):
     if self._started:
         if self.threaded:
             _ = _thread.notify(self.thID, _thread.EXIT)
Esempio n. 10
0
 def stop(self):
     # Notify thread to EXIT
     _thread.notify(self.th, _thread.EXIT)