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
9 changes: 8 additions & 1 deletion AsyncLibrary/robot_async.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ def async_get(self, handle):
assert handle in self._thread_pool, 'Invalid async call handle'
result = self._thread_pool[handle].result_queue.get()
del self._thread_pool[handle]
if isinstance(result, Exception):
raise result
return result

def _get_handler_from_keyword(self, keyword):
Expand All @@ -45,8 +47,13 @@ def wrapped_f(q, *args, **kwargs):
f = self._get_handler_from_keyword(keyword)
ret = f.run(EXECUTION_CONTEXTS.current, args)
q.put(ret)
def run_in_thread(q, *args, **kwargs):
try:
wrapped_f(q, *args, **kwargs)
except Exception:
q.put(sys.exc_info()[1])

q = queue.Queue()
t = threading.Thread(target=wrapped_f, args=(q,)+args, kwargs=kwargs)
t = threading.Thread(target=run_in_thread, args=(q,)+args, kwargs=kwargs)
t.result_queue = q
return t