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

Unable to use "timeout" argument in gateway instantiation #262

Open
kristianwiklund opened this issue Jul 5, 2020 · 3 comments · May be fixed by #436
Open

Unable to use "timeout" argument in gateway instantiation #262

kristianwiklund opened this issue Jul 5, 2020 · 3 comments · May be fixed by #436

Comments

@kristianwiklund
Copy link

Version:

pymysensors 0.20.1, installed by pip3

Environment:

Ubuntu 18.04.4 LTS, x86_64, python 3.6.9

Expected behavior

Instantiation of a tcp gateway object with altered timeouts. (If my testing of different versions isn't completely off, this worked in 0.18.0, but not from 0.19.0 and onwards.)

Actual behavior

TypeError: init() got an unexpected keyword argument 'timeout'

python3 mystest.py
Traceback (most recent call last):
  File "mystest.py", line 10, in <module>
    persistence_file='mysensors.pickle', protocol_version='1.4')
  File "/usr/local/lib/python3.6/dist-packages/mysensors/gateway_tcp.py", line 76, in __init__
    super().__init__(transport, *args, **kwargs)
  File "/usr/local/lib/python3.6/dist-packages/mysensors/__init__.py", line 197, in __init__
    super().__init__(*args, **kwargs)
  File "/usr/local/lib/python3.6/dist-packages/mysensors/gateway_tcp.py", line 23, in __init__
    super().__init__(**kwargs)
TypeError: __init__() got an unexpected keyword argument 'timeout'

How to recreate:

Use code in README to instantiate a tcp gateway with a timeout as below

import mysensors.mysensors as mysensors

def event(message):
    """Callback for mysensors updates."""
    print("sensor_update " + str(message.node_id))

GATEWAY = mysensors.TCPGateway(
    '10.168.0.2', port=5003, timeout=1.0, reconnect_timeout=10.0,
    event_callback=event, persistence=True,
    persistence_file='mysensors.pickle', protocol_version='1.4')

GATEWAY.start()
@MartinHjelmare
Copy link
Collaborator

Thanks for the report! I see the problem. We need to pop the timeout parameters from kwargs before passing kwargs on to the parent gateway.

transport = SyncTransport(self, sync_connect, **kwargs)
super().__init__(transport, *args, **kwargs)

@softerra
Copy link

The same issue applies to use of 'reconnect_timeout' parameter and serial gateway as well.

alex18-d pushed a commit to alex18-d/pymysensors that referenced this issue Jan 19, 2022
…ss constructors chain: everyone takes params it wants and ignores the rest silently
@createcandle
Copy link

I noticed this too.

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.

3 participants