openbci-archive / OpenBCI_Python

The Python software library designed to work with OpenBCI hardware.
MIT License
510 stars 207 forks source link

stop wifi asyncore loop #126

Open ai2010 opened 5 years ago

ai2010 commented 5 years ago

Hi I modified the wifi.py to stop after a certain time , specifically the loop function

def loop(self,timeloop=None):
    if timeloop:
        self.thread = threading.Thread(target=asyncore.loop, kwargs={'timeout': 1})
        self.thread.setDaemon(True)
        self.thread.start()
        time.sleep(timeloop)
        self.local_wifi_server.close()
        self.thread.join(timeout=1)
        return
    else:
        asyncore.loop()

I hope it can be useful to someone