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

Fix timeouts on Unix platform #10

Merged
merged 1 commit into from
Jan 15, 2018

Conversation

SteveEasley
Copy link
Contributor

Replaces all time.clock() calls with time.time(). On the the Unix platform time.clock() is not wall-time like it is on Windows. It results in timeouts that last orders of magnitude longer than expected on the Ubunutu 16.04 system I am working on. For instance this code was talking over an hour to finish:

xbee = ZigBeeDevice("/dev/ttyUSB0", 9600)
xbee.open()

xnet = xbee.get_network()
xnet.set_discovery_timeout(3.2)

xnet.start_discovery_process()
while xnet.is_discovery_running():
    time.sleep(0.5)

# >>> would take over an hour or more to get here

for device in xnet.get_devices():
    print(device)

print('done')

Also time.clock() is depreciated.

My PR is very untested beyond the code I provided above as I have just begun using the lib. So more testing is needed.

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 this pull request may close these issues.

None yet

2 participants