Re: MicroPython version 1.19 released -- question regarding umodulename' vs modulename
Posted: Sat Aug 20, 2022 11:56 pm
I am extremely impressed and gratified by the development team efforts! MicroPython is an amazing piece of work.
Yesterday I upgraded my firmware development software (MicroPython 1.15, ESP-IDF 4.1) to MicroPython 1.19, ESP-IDF 4.4.1, using a clean installation. I'm very happy to see increasing new functionality for the ESP32 -- BUT, as expected, my code (pretty extensive, using multiple custom modules) has broken due to changes. I've read through the github releases posts for v1.16 through 1.19, as well as the analogous forum posts, and have not been able to figure out what has impacted the problems I'm seeing in my code. So, I have a few questions here:
(1) For some reason, now 'import os' (for example) doesn't allow one to access any os.<methods>, and instead I'm having to revert to 'import uos'. The former style worked in v1.15; what has changed to affect this? (this isn't a major problem and I can easily fix it)
(2) My larger-issue problem is that, due to hardware being unique, I had chosen the singleton approach to hardware-related classes, and classes that it makes sense to use only one instantiation for, in order to cleanly share global variables across many modules. Putting aside anyone's distaste for singletons, this approach worked for my project, and had no troubles while using v1.15. However, in v1.19, now I'm getting a "TypeError: 'module' object isn't callable" runtime error related to the @singleton decorator I've been using. For the record, the implementation I've been using is Peter Hinch's, from https://github.com/peterhinch/micropyth ... _singleton .
For some reason, if I have @singleton-decorated 'MyClass' defined in 'mymodule', importing the class via 'from mymodule import MyClass' and instantiating it in a different module _sometimes_ generates a runtime error (1 out of 3 runs, about). I'm having problems understanding why this error is occurring... For the record, I'm not an extremely experienced Python developer but have used my project to learn the language, especially the specifics relating to MicroPython. On occasion, I've had to rejigger CPython modules to work with MicroPython, and have had some success with that (for example, with 'datetime' module). However, I'm stumped here, and bothered that this error never occurred when using v1.15 but now occurs inconsistently, when it's difficult to know how to mitigate it.
Apologies for the long post! Perhaps this needed it's own posting thread, but I posted it here because it's directly correlated with my software upgrades. Thank you very much in advance for anyone who could give me some insight, and thanks again to all the developers, who have done such a fantastic job / labor of 'love'.
Yesterday I upgraded my firmware development software (MicroPython 1.15, ESP-IDF 4.1) to MicroPython 1.19, ESP-IDF 4.4.1, using a clean installation. I'm very happy to see increasing new functionality for the ESP32 -- BUT, as expected, my code (pretty extensive, using multiple custom modules) has broken due to changes. I've read through the github releases posts for v1.16 through 1.19, as well as the analogous forum posts, and have not been able to figure out what has impacted the problems I'm seeing in my code. So, I have a few questions here:
(1) For some reason, now 'import os' (for example) doesn't allow one to access any os.<methods>, and instead I'm having to revert to 'import uos'. The former style worked in v1.15; what has changed to affect this? (this isn't a major problem and I can easily fix it)
(2) My larger-issue problem is that, due to hardware being unique, I had chosen the singleton approach to hardware-related classes, and classes that it makes sense to use only one instantiation for, in order to cleanly share global variables across many modules. Putting aside anyone's distaste for singletons, this approach worked for my project, and had no troubles while using v1.15. However, in v1.19, now I'm getting a "TypeError: 'module' object isn't callable" runtime error related to the @singleton decorator I've been using. For the record, the implementation I've been using is Peter Hinch's, from https://github.com/peterhinch/micropyth ... _singleton .
For some reason, if I have @singleton-decorated 'MyClass' defined in 'mymodule', importing the class via 'from mymodule import MyClass' and instantiating it in a different module _sometimes_ generates a runtime error (1 out of 3 runs, about). I'm having problems understanding why this error is occurring... For the record, I'm not an extremely experienced Python developer but have used my project to learn the language, especially the specifics relating to MicroPython. On occasion, I've had to rejigger CPython modules to work with MicroPython, and have had some success with that (for example, with 'datetime' module). However, I'm stumped here, and bothered that this error never occurred when using v1.15 but now occurs inconsistently, when it's difficult to know how to mitigate it.
Apologies for the long post! Perhaps this needed it's own posting thread, but I posted it here because it's directly correlated with my software upgrades. Thank you very much in advance for anyone who could give me some insight, and thanks again to all the developers, who have done such a fantastic job / labor of 'love'.