Skip to content

"Address already in use" when quickly run tinytuya script for two different devices #320

Closed Answered by uzlonewolf
castus asked this question in Q&A
Discussion options

You must be logged in to vote

The issue is you are not specifying the IP address of the device. This causes both threads to try and listen for the device broadcast packets at the same time. We can work around the "Address already in use" error by setting the SO_REUSEPORT socket option, however that will not help in your case as devices only broadcast once every 5 seconds thereby causing a random delay before your devices will react to the commands you're sending. Instead, you will need to either include the IPs in your script, or do a scan from your main thread and pass the IPs to the subprocess. To do a scan for just a few specific devices:

import tinytuya.scanner

want_devices = ['eb...1', 'eb...2', ...]
found = tin…

Replies: 2 comments 5 replies

Comment options

You must be logged in to vote
5 replies
@castus
Comment options

@uzlonewolf
Comment options

@castus
Comment options

@uzlonewolf
Comment options

@castus
Comment options

Answer selected by castus
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants