def _work(self): self._scheduled = False try: self._tick() except Exception as e: # Only print the exception if the watch provides a way to do so! if 'print_exception' in dir(watch): watch.print_exception(e) self.switch(CrashApp(e))
def _work(self): self._scheduled = False try: self._tick() except MemoryError: self.switch( PagerApp( "Your watch is low on memory.\n\nYou may want to reboot.")) except Exception as e: # Only print the exception if the watch provides a way to do so! if 'print_exception' in dir(watch): watch.print_exception(e) self.switch(CrashApp(e))
def run(self, no_except=True): """Run the system manager synchronously. This allows all watch management activities to handle in the normal execution context meaning any exceptions and other problems can be observed interactively via the console. """ global free if self._scheduling: print('Watch already running in the background') return if not self.app: self.switch(self.quick_ring[0]) if watch.free: gc.collect() free = gc.mem_free() # Reminder: wasptool uses this string to confirm the device has # been set running again. print('Watch is running, use Ctrl-C to stop') if not no_except: # This is a simplified (uncommented) version of the loop # below while True: self._tick() machine.deepsleep() while True: try: self._tick() except KeyboardInterrupt: raise except Exception as e: # Only print the exception if the watch provides a way to do so! if 'print_exception' in dir(watch): watch.print_exception(e) self.switch(CrashApp(e)) # Currently there is no code to control how fast the system # ticks. In other words this code will break if we improve the # power management... we are currently relying on not being able # to stay in the low-power state for very long. machine.deepsleep()