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: handling KeyboardInterrupt: lower level closes the socket automa… #33

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 24 additions & 16 deletions vxi11/vxi11.py
Original file line number Diff line number Diff line change
Expand Up @@ -677,13 +677,17 @@ def write_raw(self, data):

block = data[offset:offset+self.max_recv_size]

error, size = self.client.device_write(
self.link,
self._timeout_ms,
self._lock_timeout_ms,
flags,
block
)
try:
error, size = self.client.device_write(
self.link,
self._timeout_ms,
self._lock_timeout_ms,
flags,
block
)
except KeyboardInterrupt:
self.link = None
raise

if error:
raise Vxi11Exception(error, 'write')
Expand Down Expand Up @@ -714,15 +718,19 @@ def read_raw(self, num=-1):
read_data = bytearray()

while reason & (RX_END | RX_CHR) == 0:
error, reason, data = self.client.device_read(
self.link,
read_len,
self._timeout_ms,
self._lock_timeout_ms,
flags,
term_char
)

try:
error, reason, data = self.client.device_read(
self.link,
read_len,
self._timeout_ms,
self._lock_timeout_ms,
flags,
term_char
)
except KeyboardInterrupt:
self.link = None
raise

if error:
raise Vxi11Exception(error, 'read')

Expand Down