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

aiothreads: More Informative timeout message #1

Closed
chrisjsewell opened this issue Feb 17, 2021 · 1 comment
Closed

aiothreads: More Informative timeout message #1

chrisjsewell opened this issue Feb 17, 2021 · 1 comment

Comments

@chrisjsewell
Copy link

chrisjsewell commented Feb 17, 2021

From aiidateam/aiida-core#4745, it might be helpful to allow for a more informative error message here:

pytray/pytray/aiothreads.py

Lines 146 to 155 in 371b22e

def await_(self, awaitable: typing.Awaitable):
"""
Await an awaitable on the event loop and return the result. It may take a little time for
the loop to get around to scheduling it so we use a timeout as set by the TASK_TIMEOUT class
constant.
:param awaitable: the coroutine to run
:return: the result of running the coroutine
"""
return self.await_submit(awaitable).result(timeout=self.task_timeout)

along the lines of:

def await_(self, awaitable: typing.Awaitable, exc_msg: str = ""):
    try:
	    return self.await_submit(awaitable).result(timeout=self.task_timeout)
    except TimeoutError:
	    raise TimeoutError(f"{exc_msg} after {self.task_timeout} seconds")
@chrisjsewell chrisjsewell changed the title More Informative timeout message aiothreads: More Informative timeout message Feb 17, 2021
@muhrin
Copy link
Owner

muhrin commented May 21, 2021

Thanks Chris! This has been added in #3f225bea803188fee7d8ba0a8dcb78cc0ef52a3b.

@muhrin muhrin closed this as completed May 21, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants