def background_thread(self): print('processing clients') x = 0 while True: socketio.sleep(.25) sys.stdout.flush() # update log sids = list(self.clients) for sid in sids: if not sid in self.clients: print('client was removed') continue # was removed client = self.clients[sid] values = client.list_values() if values: #print('values', values) socketio.emit('pypilot_values', pyjson.dumps(values), room=sid) if not client.connection: socketio.emit('pypilot_disconnect', room=sid) msgs = client.receive() if msgs: # convert back to json (format is nicer) socketio.emit('pypilot', pyjson.dumps(msgs), room=sid)
def write_config(self): try: f = open(self.configfilename, 'w') f.write(pyjson.dumps(self.config) + '\n') f.close() except IOError: print('failed to save config file:', self.configfilename)