mirror of https://github.com/joan2937/pigpio
Refine error handling approach
This commit is contained in:
parent
8f7868052c
commit
e3a7548f4e
|
@ -980,12 +980,8 @@ def _pigpio_command(sl, cmd, p1, p2, rl=True):
|
||||||
p2:= command parameter 2 (if applicable).
|
p2:= command parameter 2 (if applicable).
|
||||||
"""
|
"""
|
||||||
sl.l.acquire()
|
sl.l.acquire()
|
||||||
try:
|
|
||||||
sl.s.send(struct.pack('IIII', cmd, p1, p2, 0))
|
sl.s.send(struct.pack('IIII', cmd, p1, p2, 0))
|
||||||
dummy, res = struct.unpack('12sI', sl.s.recv(_SOCK_CMD_LEN))
|
dummy, res = struct.unpack('12sI', sl.s.recv(_SOCK_CMD_LEN))
|
||||||
except Exception, e:
|
|
||||||
sl.l.release()
|
|
||||||
raise(e)
|
|
||||||
if rl: sl.l.release()
|
if rl: sl.l.release()
|
||||||
return res
|
return res
|
||||||
|
|
||||||
|
@ -1007,12 +1003,8 @@ def _pigpio_command_ext(sl, cmd, p1, p2, p3, extents, rl=True):
|
||||||
else:
|
else:
|
||||||
ext.extend(x)
|
ext.extend(x)
|
||||||
sl.l.acquire()
|
sl.l.acquire()
|
||||||
try:
|
|
||||||
sl.s.sendall(ext)
|
sl.s.sendall(ext)
|
||||||
dummy, res = struct.unpack('12sI', sl.s.recv(_SOCK_CMD_LEN))
|
dummy, res = struct.unpack('12sI', sl.s.recv(_SOCK_CMD_LEN))
|
||||||
except Exception, e:
|
|
||||||
sl.l.release()
|
|
||||||
raise(e)
|
|
||||||
if rl: sl.l.release()
|
if rl: sl.l.release()
|
||||||
return res
|
return res
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue