Skip to content

Commit

Permalink
Add missing sock.close() to rpc _connect() (#388)
Browse files Browse the repository at this point in the history
The socket was not closed if the _connect() function timed out.
This lead to an unclosed socket every time a second instance of
pyvisa attempted to connect to a device while the first instance
of pyvisa still had an open connection.

With this fix, the second instance can back off and try again at
a later time without reaching an irrecoverable state.
  • Loading branch information
ACharlyR committed Jul 27, 2023
1 parent c33f4f2 commit dc58253
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGES
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ PyVISA-py Changelog
------------------

- add support for GPIB secondary addresses
- fix missing sock.close() in rpc _connect()

0.7.0 (05/05/2023)
------------------
Expand Down
1 change: 1 addition & 0 deletions pyvisa_py/protocols/rpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -437,6 +437,7 @@ def _connect(sock, host, port, timeout=0):

if time.time() >= finish_time:
# reached timeout
sock.close()
return False

# `select_timout` decreased to 50% of previous or min_select_timeout
Expand Down

0 comments on commit dc58253

Please sign in to comment.