Beispiel #1
0
def _acceptWebSocketCallback(webSocket, httpClient):
    if WS_messages:
        print("WS ACCEPT")
        _thread.list()
    webSocket.RecvTextCallback = _recvTextCallback
    webSocket.RecvBinaryCallback = _recvBinaryCallback
    webSocket.ClosedCallback = _closedCallback
def _acceptWebSocketCallback(webSocket, httpClient):
    if WS_messages:
        print("WS ACCEPT")
        if ws_run_in_thread or srv_run_in_thread:
            # Print thread list so that we can monitor maximum stack size
            # of WebServer thread and WebSocket thread if any is used
            _thread.list()
    webSocket.RecvTextCallback = _recvTextCallback
    webSocket.RecvBinaryCallback = _recvBinaryCallback
    webSocket.ClosedCallback = _closedCallback
Beispiel #3
0
 def _OnWebSocketAcceptedCallback(self, microWebSrv2, webSocket):
     if WS_messages:
         if ws_run_in_thread or srv_run_in_thread:
             # Print thread list so that we can monitor maximum stack size
             # of WebServer thread and WebSocket thread if any is used
             _thread.list()
     webSocket.OnTextMessage = self._OnTextMessageCallback
     webSocket.OnBinaryMessage = self._OnBinaryMessageCallback
     webSocket.OnClosed = self._OnClosedCallback
     webSocket.thing = self.thing
     self.thing.add_subscriber(webSocket)
Beispiel #4
0
 def __call__(self, *args):
     print(yellow('Shutting down Wroombian...'))
     threads = thread.list(False)
     for t in threads:
         thread.stop(t[0])
     gc.collect()
     sys.exit()
 def _acceptWebSocketCallback(self, webSocket, httpClient):
     reqPath = httpClient.GetRequestPath()
     if WS_messages:
         print('WS ACCEPT reqPath =', reqPath)
         if ws_run_in_thread or srv_run_in_thread:
             # Print thread list so that we can monitor maximum stack size
             # of WebServer thread and WebSocket thread if any is used
             _thread.list()
     webSocket.RecvTextCallback = self._recvTextCallback
     webSocket.RecvBinaryCallback = self._recvBinaryCallback
     webSocket.ClosedCallback = self._closedCallback
     things = self.things.get_things()
     if len(things) == 1:
         thing_id = 0
     else:
         thing_id = int(reqPath.split('/')[1])
     thing = things[thing_id]
     webSocket.thing = thing
     thing.add_subscriber(webSocket)
Beispiel #6
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
Beispiel #7
0
 def __call__(self, *args):
     if len(args[1]) > 0:
         if 'list' in args[1]:
             threads = thread.list(False)
             states = {0: green('Running'), 1: yellow('Suspended'), 2: yellow('Waiting'), 3: red('Terminated')}
             types = {1: purple('MAIN'), 2: lPurple('PYTHON'), 3: cyan('SERVICE')}
             print(yellow('ID               Name               State          Stack      Max stack used       Type'))
             for t in threads:
                 print(str(t[0]) + makeTab(str(t[0]), 17) + t[2] + makeTab(t[2], 19) + states[t[3]] + makeTab(states[t[3]], 24) + str(t[4]) + makeTab(str(t[4]), 11) + str(t[5]) + makeTab(str(t[5]), 21) + types[t[1]])
         elif 'resume' in args[1] and len(args[1]) > 1 and args[1][1].isdigit():
             thread.resume(int(args[1][1]))
         elif 'pause' in args[1] and len(args[1]) > 1 and args[1][1].isdigit():
             thread.suspend(int(args[1][1]))
         elif 'stop' in args[1] and len(args[1]) > 1 and args[1][1].isdigit():
             thread.stop(int(args[1][1]))
         else:
             print(red('No valid parameters provided'))
             print(self.help)
     else:
         print(red('No parameters provided'))
         print(self.help)
Beispiel #8
0
            if ntf == 1001:  # 获取数据
                # print(internet_date)
                display()
                gc_count += 1
                # gc.collect()

        # 将debug_date 数据显示到debug窗口
        if len(debug_date) > 0:
            de(debug_date[0])
            del debug_date[0]
            gc_count += 1

        if gc_count > 20:
            gc.collect()
            gc_count = 0


window.page.append(page1)
window.page.append(page2)
window.active()

# thread.stack_size(1024*8*10)

thread.stack_size(1024 * 8 * 10)
main_thread = thread.start_new_thread('main', main, ())  # windows线程
get_date_thread = thread.start_new_thread('get_date', get_date,
                                          (main_thread, ))  # 获取数据线程

machine.heap_info()
thread.list()
Beispiel #9
0
    pos = 0
    bri = 0.02
    while True:
        for i in range(0, 24):
            dHue = 360.0 / 24 * (pos + i)
            hue = dHue % 360
            np.setHSB(i, hue, 1.0, bri, 1, False)
        np.show()
        notif = _thread.getnotification()
        if (notif > 0) and (notif <= 100):
            bri = notif / 100.0
        elif notif == 1000:
            _thread.sendmsg(
                _thread.getReplID(),
                "[%s] Run counter = %u" % (_thread.getSelfName(), pos))
        pos = pos + 1


# Start the Neopixels thread
npth = _thread.start_new_thread("Neopixel", thrainbow, ())

utime.sleep(1)

machine.heap_info()
_thread.list()

# Set neopixel brightnes (%)
#_thread.notify(npth, 20)
# Get counter value from Neopixel thread
#_thread.notify(npth, 1000)
 def _closedCallback(self, webSocket):
     if WS_messages:
         if ws_run_in_thread or srv_run_in_thread:
             _thread.list()
         print('WS CLOSED')
Beispiel #11
0
def _closedCallback(webSocket):
    if WS_messages:
        _thread.list()
        print("WS CLOSED")