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

A stacktrace is printed when no user CB is provided in the constructor #8

Open
baldoalessandro opened this issue Aug 19, 2019 · 0 comments
Labels
bug Something isn't working good first issue Good for newcomers

Comments

@baldoalessandro
Copy link
Contributor

baldoalessandro commented Aug 19, 2019

How to reproduce

>>> import iottly_sdk
>>> sdk = iottly_sdk.IottlySDK("Wilson")
>>> sdk.start()
>>> Exception in thread receiver_t:
Traceback (most recent call last):
  File "/usr/lib/python3.5/threading.py", line 914, in _bootstrap_inner
    self.run()
  File "/usr/lib/python3.5/threading.py", line 862, in run
    self._target(*self._args, **self._kwargs)
  File "/usr/local/lib/python3.5/dist-packages/iottly_sdk-1.3.0-py3.5.egg/iottly_sdk/iottly.py", line 486, in _receive_msgs_from_agent
    self._process_msg_from_agent(msg)
  File "/usr/local/lib/python3.5/dist-packages/iottly_sdk-1.3.0-py3.5.egg/iottly_sdk/iottly.py", line 506, in _process_msg_from_agent
    self._handle_signals_from_agent(msg['signal'])
  File "/usr/local/lib/python3.5/dist-packages/iottly_sdk-1.3.0-py3.5.egg/iottly_sdk/iottly.py", line 519, in _handle_signals_from_agent
    self._on_connection_status_changed_cb(status)
TypeError: 'NoneType' object is not callable

Cause

def _handle_signals_from_agent(self, signal):
if 'agentstatus' in signal:
status = signal['agentstatus'] # TODO validate status
self._on_agent_status_changed_cb(status)
elif 'connectionstatus' in signal:
status = signal['connectionstatus'] # TODO validate status
self._on_connection_status_changed_cb(status)

The invocations should be guarded like in
if self._on_agent_status_changed_cb:
self._on_agent_status_changed_cb('started')

Thanks to @Oscar-Campo and @lupodellasleppa 🎖️

@baldoalessandro baldoalessandro added bug Something isn't working good first issue Good for newcomers labels Aug 19, 2019
@SaiT2 SaiT2 mentioned this issue Oct 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

1 participant