Skip to content

Commit 87cd2c2

Browse files
author
Ulf Dambacher
committed
Revert "fix error handling with locking"
This reverts commit 5ed5ad7.
1 parent 57d9c71 commit 87cd2c2

1 file changed

Lines changed: 16 additions & 32 deletions

File tree

vxi11_server/instrument_server.py

Lines changed: 16 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -335,10 +335,8 @@ def handle_11(self):
335335
elif len(opaque_data) > MAX_RECEIVE_SIZE:
336336
error = vxi11.ERR_PARAMETER_ERROR
337337
else:
338-
with self.device.lock(link_id, flags, lock_timeout) as error1:
339-
if error1 != vxi11.ERR_NO_ERROR:
340-
error = error1
341-
else:
338+
with self.device.lock(link_id, flags, lock_timeout) as error:
339+
if error == vxi11.ERR_NO_ERROR:
342340
error = self.device.device_write(opaque_data, flags, io_timeout)
343341

344342
result = (error, 0)
@@ -372,10 +370,8 @@ def handle_12(self):
372370
except KeyError:
373371
error = vxi11.ERR_DEVICE_NOT_ACCESSIBLE
374372
else:
375-
with self.device.lock(link_id, flags, lock_timeout) as error1:
376-
if error1 != vxi11.ERR_NO_ERROR:
377-
error = error1
378-
else:
373+
with self.device.lock(link_id, flags, lock_timeout) as error:
374+
if error == vxi11.ERR_NO_ERROR:
379375
error, reason, opaque_data = self.device.device_read(request_size, term_char, flags, io_timeout)
380376

381377
result = (error, reason, opaque_data)
@@ -405,10 +401,8 @@ def handle_13(self):
405401
except KeyError:
406402
error = vxi11.ERR_DEVICE_NOT_ACCESSIBLE
407403
else:
408-
with self.device.lock(link_id, flags, lock_timeout) as error1:
409-
if error1 != vxi11.ERR_NO_ERROR:
410-
error = error1
411-
else:
404+
with self.device.lock(link_id, flags, lock_timeout) as error:
405+
if error == vxi11.ERR_NO_ERROR:
412406
error, stb = self.device.device_readstb(flags, io_timeout)
413407

414408
result = (error, stb)
@@ -436,10 +430,8 @@ def handle_14(self):
436430
except KeyError:
437431
error = vxi11.ERR_DEVICE_NOT_ACCESSIBLE
438432
else:
439-
with self.device.lock(link_id, flags, lock_timeout) as error1:
440-
if error1 != vxi11.ERR_NO_ERROR:
441-
error = error1
442-
else:
433+
with self.device.lock(link_id, flags, lock_timeout) as error:
434+
if error == vxi11.ERR_NO_ERROR:
443435
error = self.device.device_trigger(flags, io_timeout)
444436

445437
self.turn_around()
@@ -469,10 +461,8 @@ def handle_15(self):
469461
except KeyError:
470462
error = vxi11.ERR_DEVICE_NOT_ACCESSIBLE
471463
else:
472-
with self.device.lock(link_id, flags, lock_timeout) as error1:
473-
if error1 != vxi11.ERR_NO_ERROR:
474-
error = error1
475-
else:
464+
with self.device.lock(link_id, flags, lock_timeout) as error:
465+
if error == vxi11.ERR_NO_ERROR:
476466
error = self.device.device_clear(flags, io_timeout)
477467

478468
self.turn_around()
@@ -492,10 +482,8 @@ def handle_16(self):
492482
if self.device.primary is not None and self.device.secondary is None:
493483
error=vxi11.ERR_OPERATION_NOT_SUPPORTED
494484
else:
495-
with self.device.lock.is_open(link_id, flags, lock_timeout) as error1:
496-
if error1 != vxi11.ERR_NO_ERROR:
497-
error = error1
498-
else:
485+
with self.device.lock.is_open(link_id, flags, lock_timeout) as error:
486+
if error == vxi11.ERR_NO_ERROR:
499487
error = self.device.device_remote(flags, io_timeout)
500488

501489
self.turn_around()
@@ -516,10 +504,8 @@ def handle_17(self):
516504
if self.device.primary is not None and self.device.secondary is None:
517505
error=vxi11.ERR_OPERATION_NOT_SUPPORTED
518506
else:
519-
with self.device.lock(link_id, flags, lock_timeout) as error1:
520-
if error != vxi11.ERR_NO_ERROR:
521-
error = error1
522-
else:
507+
with self.device.lock(link_id, flags, lock_timeout) as error:
508+
if error == vxi11.ERR_NO_ERROR:
523509
error = self.device.device_local(flags, io_timeout)
524510

525511
self.turn_around()
@@ -640,10 +626,8 @@ def handle_22(self):
640626
logger.debug("command link %i != current device link %i)",link_id, self.link_id)
641627
error = vxi11.ERR_INVALID_LINK_IDENTIFIER
642628
else:
643-
with self.device.lock(link_id, flags, lock_timeout) as error1:
644-
if error1 != vxi11.ERR_NO_ERROR:
645-
error = error1
646-
else:
629+
with self.device.lock(link_id, flags, lock_timeout) as error:
630+
if error == vxi11.ERR_NO_ERROR:
647631
error, opaque_data_out = self.device.device_docmd(flags, io_timeout, cmd, network_order, data_size, opaque_data_in)
648632

649633
result = error, opaque_data_out

0 commit comments

Comments
 (0)