• Does that error happen exactly once every 40 seconds? Maybe you could add a print before and after updateServices to see if it is that which is causing the problem?

    Because generally that error happens if you Ctrl-C out of something that was taking a long time to execute (or some event handler causes the device to run out of memory) but not much else