Skip to content
This repository has been archived by the owner on Sep 4, 2021. It is now read-only.

retry if material down /and resolve set_timer on specific port #63

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

vBlackOut
Copy link

No description provided.

@vBlackOut vBlackOut changed the title retry if material down retry if material down /and resolve set time on specific port Nov 8, 2019
@vBlackOut vBlackOut changed the title retry if material down /and resolve set time on specific port retry if material down /and resolve set_timer on specific port Nov 8, 2019
Copy link
Owner

@clach04 clach04 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for looking to improve this! Some minor changes needed before they can be accepted

@@ -136,18 +136,18 @@ def hex2bin(x):
}

class XenonDevice(object):
def __init__(self, dev_id, address, local_key=None, dev_type=None, connection_timeout=10):
def __init__(self, dev_id, address, local_key=None, dev_type=None, connection_timeout=20):
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

timeout should stay the same.

retry code below is a nice idea, this should be a parameter and default to 1.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the connect WiFi is slow the material didn't réponse correctly

s.connect((self.address, self.port))
except (ConnectionRefusedError, ConnectionAbortedError):
pass
time.sleep(1)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sleep should be in the except block

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, if don't wait your send so fast request and don't wait correctly for retry connection

Comment on lines 178 to 185
try:
s.connect((self.address, self.port))
except (ConnectionRefusedError, ConnectionAbortedError):
for i in range(0, 3):
try:
s.connect((self.address, self.port))
except (ConnectionRefusedError, ConnectionAbortedError):
pass
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this tries 4 times. Remove one of the try/except blocks and move into a for loop.

retry cont should come from self.retry_count (set in __init__)

Comment on lines 189 to 196
# try/except for resolve connection reset error.
try:
data = s.recv(1024)
except:
s.close()
return None
s.close()
return data
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should be in a try/finally

Comment on lines 372 to 378
if self.set_status(True, switch) == None:
for i in range(0, 3):
if self.set_status(True, switch) == None:
continue
else:
return True
return False
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this looks like retry logic - use self.retry_count

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes correctly

Comment on lines 384 to 392
if self.set_status(False, switch) == None:
for i in range(0, 3):
if self.set_status(False, switch) == None:
continue
else:
return True
return False
else:
return True
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks like retry logic, should use retry count

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again correctly

Comment on lines 377 to 417
dps_id = devices_numbers[-1]
print(devices_numbers)
dps_list = []
for dps in devices_numbers:
if int(dps) > 5:
dps_list.append(int(dps))
dps_list.sort()

if number_dps >= 1 and number_dps <=4:
number_dps = number_dps-1

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not entirely sure what this is doing - it needs an explanation

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hum if for detect the plug number > 4 but the return true or false or numerical I check for fix last time

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants