Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BlynkTimer Broken on Low Memory Ports #5

Closed
BradenM opened this issue Jun 20, 2019 · 1 comment · Fixed by #6
Closed

BlynkTimer Broken on Low Memory Ports #5

BradenM opened this issue Jun 20, 2019 · 1 comment · Fixed by #6

Comments

@BradenM
Copy link
Contributor

BradenM commented Jun 20, 2019

Expected Behavior

Registering a Timer via register decorator should work on devices with low memory.

Actual Behavior

An AttributeError is raised, complaining that a function object has no attribute 'func', as this seems to be the current fallback if a __name__ attribute cannot be found. This completely breaks BlynkTimer on low memory ports.

Steps to Reproduce the Problem

from blynktimer import Timer

timer = Timer()

@timer.register(interval=1)
def test():
   print('Hello!')

while 1:
   timer.run()

Traceback (most recent call last):
 File "<stdin>", line 1, in <module>
 File "main.py", line 8, in start
 File "/lib/blynktimer.py", line 58, in __init__
 File "/lib/blynktimer.py", line 48, in _get_func_name
AttributeError: 'function' object has no attribute 'func'

Specifications

  • Version: MicroPython Official v1.11.0
  • Platform: ESP8266
BradenM added a commit to BradenM/lib-python that referenced this issue Jun 20, 2019
On low memory ports MICROPY_PY_FUNCTION_ATTRS is disabled, leading BlynkTimer to raise an AttributeError when trying to get a name for a new timer. This fixes it by naming each timer 'X_timer' (where X is the # of timer) if the __name__ attribute does not exist.

Fixes blynkkk#5
@antohaUa
Copy link
Collaborator

Added one comment to your pull request. And Thanks for your investigation.

antohaUa pushed a commit that referenced this issue Jun 20, 2019
* fix(timer): BlynkTimer Broken on Low Memory Ports

On low memory ports MICROPY_PY_FUNCTION_ATTRS is disabled, leading BlynkTimer to raise an AttributeError when trying to get a name for a new timer. This fixes it by naming each timer 'X_timer' (where X is the # of timer) if the __name__ attribute does not exist.

Fixes #5

* docs(timer): Added note about Low Memory ports

* feat(timer): Cleanup Code, handle all cases

* docs(timer): Added some docstrings for clarification
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants