Skip to content
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
23 changes: 18 additions & 5 deletions src/p4p/client/thread.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,15 +259,22 @@ def cb(value, i=i):
_log.debug('get %s w/ %s', N, req)
ops[i] = raw_get(N, cb, request=req)

pending = set(range(len(name)))
for _n in range(len(name)):
try:
value, i = done.get(timeout=timeout)
except Empty:
result[i] = TimeoutError(name[i])
# 'done' is a shared queue, so we can't know which PV timed
# out; mark every still-pending PV as timed out rather than
# reusing the loop's stale 'i' (which points at the wrong PV).
for j in pending:
result[j] = TimeoutError(name[j])
if throw:
_log.debug('timeout %s after %s', name[i], timeout)
raise result[i]
j = next(iter(pending))
_log.debug('timeout %s after %s', name[j], timeout)
raise result[j]
break
pending.discard(i)
_log.debug('got %s %r', name[i], value)
if throw and isinstance(value, Exception):
raise value
Expand Down Expand Up @@ -358,14 +365,20 @@ def cb(value, i=i):

ops[i] = raw_put(n, cb, builder=value, request=req, get=get)

pending = set(range(len(name)))
for _n in range(len(name)):
try:
value, i = done.get(timeout=timeout)
except Empty:
result[i] = TimeoutError(name[i])
# 'done' is a shared queue, so we can't know which PV timed
# out; mark every still-pending PV rather than reusing the
# loop's stale 'i' (which points at the wrong PV).
for j in pending:
result[j] = TimeoutError(name[j])
if throw:
raise result[i]
raise result[next(iter(pending))]
break
pending.discard(i)
if throw and isinstance(value, Exception):
raise value
result[i] = value
Expand Down