Repository: truera/trulens
Issue: "RuntimeError: cannot reuse already awaited coroutine" 
Root cause: Resource Mishandling

I am currently using the code provided in this [Colab notebook](https://colab.research.google.com/github/truera/trulens/blob/main/trulens_eval/examples/quickstart/quickstart.ipynb#scrollTo=-HyRuVA2qR7H) to evaluate my RAG pipeline. While running the evaluation, I encountered an issue:

- RuntimeError: cannot reuse already awaited coroutine:

During the evaluation process, I encountered a RuntimeError with the message "cannot reuse already awaited coroutine" when executing the following code snippet:

```
with tru_rag as recording:
    for question in questions_500[:10]:
        answer = rag.query(question)

```
This error started occurring from yesterday, and I didn't have the same problems again. Is there any possible solution?





Thanks for reporting @kouskouss - can you create a second issue and separate these? They are not related.





> Thanks for reporting @kouskouss - can you create a second issue and separate these? They are not related.

Yes, of course.

@piotrm0 can you take a look at this awaited coroutine issue?

Having trouble replicating on main. @kouskouss can you let me know if the issue persists on the main branch of trulens_eval and the versions of pip packages and python you are using (`python --version` and `pip list` can list these)?

Problem may be related to https://github.com/truera/trulens/issues/639 . Looking for a fix.

> Having trouble replicating on main. @kouskouss can you let me know if the issue persists on the main branch of trulens_eval and the versions of pip packages and python you are using (`python --version` and `pip list` can list these)?

I am still face the same error : RuntimeError: cannot reuse already awaited coroutine when I run this:
```
with tru_rag as recording:
    for question in questions_500[:10]:
        answer = rag.query(question)
```

- python version: 3.10.13
- packages:
Package                                  Version
---------------------------------------- -------------------
absl-py                                  1.4.0
accelerate                               0.26.1
access                                   1.1.9
affine                                   2.4.0
aiobotocore                              2.11.0
aiofiles                                 22.1.0
aiohttp                                  3.9.1
aiohttp-cors                             0.7.0
aioitertools                             0.11.0
aiorwlock                                1.3.0
aiosignal                                1.3.1
aiosqlite                                0.19.0
albumentations                           1.3.1
alembic                                  1.13.1
altair                                   5.2.0
annotated-types                          0.6.0
annoy                                    1.17.3
anyio                                    4.2.0
apache-beam                              2.46.0
aplus                                    0.11.0
appdirs                                  1.4.4
archspec                                 0.2.2
argon2-cffi                              23.1.0
argon2-cffi-bindings                     21.2.0
array-record                             0.5.0
arrow                                    1.3.0
arviz                                    0.17.0
astroid                                  3.0.2
astropy                                  6.0.0
astropy-iers-data                        0.2024.1.22.0.30.30
asttokens                                2.4.1
astunparse                               1.6.3
async-lru                                2.0.4
async-timeout                            4.0.3
attrs                                    23.2.0
audioread                                3.0.1
autopep8                                 2.0.4
Babel                                    2.14.0
backoff                                  2.2.1
bayesian-optimization                    1.4.3
bayespy                                  0.5.26
beatrix_jupyterlab                       2023.128.151533
beautifulsoup4                           4.12.2
bidict                                   0.22.1
biopython                                1.83
bitsandbytes                             0.42.0
blake3                                   0.2.1
bleach                                   6.1.0
blessed                                  1.20.0
blinker                                  1.7.0
blis                                     0.7.10
blosc2                                   2.4.0
bokeh                                    3.3.3
boltons                                  23.1.1
Boruta                                   0.3
boto3                                    1.26.100
botocore                                 1.34.22
bq_helper                                0.4.1
bqplot                                   0.12.42
branca                                   0.7.0
brewer2mpl                               1.4.1
Brotli                                   1.0.9
brotlipy                                 0.7.0
cached-property                          1.5.2
cachetools                               4.2.4
Cartopy                                  0.22.0
catalogue                                2.0.10
catalyst                                 22.4
catboost                                 1.2.2
category-encoders                        2.6.3
certifi                                  2023.11.17
cesium                                   0.12.1
cffi                                     1.16.0
charset-normalizer                       3.3.2
chex                                     0.1.85
cleverhans                               4.0.0
click                                    8.1.7
click-plugins                            1.1.1
cligj                                    0.7.2
cloud-tpu-client                         0.10
cloud-tpu-profiler                       2.4.0
cloudpathlib                             0.16.0
cloudpickle                              2.2.1
cmdstanpy                                1.2.0
cmudict                                  1.0.16
colorama                                 0.4.6
colorcet                                 3.0.1
colorful                                 0.5.6
colorlog                                 6.8.0
colorlover                               0.3.0
comm                                     0.2.1
conda                                    23.7.4
conda-libmamba-solver                    23.7.0
conda-package-handling                   2.2.0
conda_package_streaming                  0.9.0
confection                               0.1.4
contextily                               1.5.0
contourpy                                1.2.0
convertdate                              2.4.0
crcmod                                   1.7
cryptography                             41.0.7
cuda-python                              12.3.0
cudf                                     23.8.0
cufflinks                                0.17.3
cuml                                     23.8.0
cupy                                     13.0.0
CVXcanon                                 0.1.2
cycler                                   0.12.1
cymem                                    2.0.8
cysignals                                1.11.4
Cython                                   3.0.8
cytoolz                                  0.12.2
daal                                     2024.1.0
daal4py                                  2024.1.0
dacite                                   1.8.1
dask                                     2024.1.0
dask-cuda                                23.8.0
dask-cudf                                23.8.0
dataclasses-json                         0.6.3
dataproc_jupyter_plugin                  0.1.66
datasets                                 2.1.0
datashader                               0.16.0
datatile                                 1.0.3
db-dtypes                                1.2.0
deap                                     1.4.1
debugpy                                  1.8.0
decorator                                5.1.1
deepdiff                                 6.7.1
defusedxml                               0.7.1
Delorean                                 1.0.0
Deprecated                               1.2.14
deprecation                              2.1.0
descartes                                1.1.0
dill                                     0.3.7
dipy                                     1.8.0
dirtyjson                                1.0.8
distlib                                  0.3.8
distributed                              2024.1.0
distro                                   1.9.0
dm-tree                                  0.1.8
docker                                   7.0.0
docker-pycreds                           0.4.0
docopt                                   0.6.2
docstring-parser                         0.15
docstring-to-markdown                    0.13
docutils                                 0.20.1
earthengine-api                          0.1.386
easydict                                 1.11
easyocr                                  1.7.1
ecos                                     2.0.12
eli5                                     0.13.0
emoji                                    2.10.0
en-core-web-lg                           3.7.1
en-core-web-sm                           3.7.1
entrypoints                              0.4
ephem                                    4.1.5
esda                                     2.5.1
essentia                                 2.1b6.dev1110
et-xmlfile                               1.1.0
etils                                    1.6.0
exceptiongroup                           1.2.0
executing                                2.0.1
explainable-ai-sdk                       1.3.3
Faker                                    23.1.0
Farama-Notifications                     0.0.4
fastai                                   2.7.13
fastapi                                  0.108.0
fastavro                                 1.9.3
fastcore                                 1.5.29
fastdownload                             0.0.7
fasteners                                0.19
fastjsonschema                           2.19.1
fastprogress                             1.0.3
fastrlock                                0.8.2
fasttext                                 0.9.2
favicon                                  0.7.0
fbpca                                    1.0
feather-format                           0.4.1
featuretools                             1.28.0
filelock                                 3.13.1
fiona                                    1.9.5
fitter                                   1.7.0
flake8                                   7.0.0
flashtext                                2.7
Flask                                    3.0.1
flatbuffers                              23.5.26
flax                                     0.7.5
folium                                   0.15.1
fonttools                                4.47.0
fqdn                                     1.5.1
frozendict                               2.4.0
frozenlist                               1.4.1
fsspec                                   2023.12.2
funcy                                    2.0
fury                                     0.9.0
future                                   0.18.3
fuzzywuzzy                               0.18.0
gast                                     0.5.4
gatspy                                   0.3
gcsfs                                    2023.12.2.post1
gensim                                   4.3.2
geographiclib                            2.0
Geohash                                  1.0
geojson                                  3.1.0
geopandas                                0.14.2
geoplot                                  0.5.1
geopy                                    2.4.1
geoviews                                 1.11.0
ggplot                                   0.11.5
giddy                                    2.3.5
gitdb                                    4.0.11
GitPython                                3.1.41
google-ai-generativelanguage             0.4.0
google-api-core                          2.11.1
google-api-python-client                 2.115.0
google-apitools                          0.5.31
google-auth                              2.26.1
google-auth-httplib2                     0.1.1
google-auth-oauthlib                     1.2.0
google-cloud-aiplatform                  0.6.0a1
google-cloud-artifact-registry           1.10.0
google-cloud-automl                      1.0.1
google-cloud-bigquery                    2.34.4
google-cloud-bigtable                    1.7.3
google-cloud-core                        2.4.1
google-cloud-datastore                   2.19.0
google-cloud-dlp                         3.14.0
google-cloud-jupyter-config              0.0.5
google-cloud-language                    2.12.0
google-cloud-monitoring                  2.18.0
google-cloud-pubsub                      2.19.0
google-cloud-pubsublite                  1.9.0
google-cloud-recommendations-ai          0.7.1
google-cloud-resource-manager            1.11.0
google-cloud-spanner                     3.40.1
google-cloud-storage                     1.44.0
google-cloud-translate                   3.12.1
google-cloud-videointelligence           2.12.0
google-cloud-vision                      2.8.0
google-crc32c                            1.5.0
google-generativeai                      0.3.2
google-pasta                             0.2.0
google-resumable-media                   2.7.0
googleapis-common-protos                 1.62.0
gplearn                                  0.4.2
gpustat                                  1.0.0
gpxpy                                    1.6.2
graphviz                                 0.20.1
greenlet                                 3.0.3
grpc-google-iam-v1                       0.12.7
grpcio                                   1.51.1
grpcio-status                            1.48.1
gviz-api                                 1.10.0
gym                                      0.26.2
gym-notices                              0.0.8
gymnasium                                0.29.0
h11                                      0.14.0
h2o                                      3.44.0.3
h5netcdf                                 1.3.0
h5py                                     3.10.0
haversine                                2.8.1
hdfs                                     2.7.3
hep-ml                                   0.7.2
hijri-converter                          2.3.1
hmmlearn                                 0.3.0
holidays                                 0.24
holoviews                                1.18.1
hpsklearn                                0.1.0
htbuilder                                0.6.2
html5lib                                 1.1
htmlmin                                  0.1.12
httpcore                                 1.0.2
httplib2                                 0.21.0
httptools                                0.6.1
httpx                                    0.26.0
huggingface-hub                          0.20.3
humanize                                 4.9.0
hunspell                                 0.5.5
husl                                     4.0.3
hydra-slayer                             0.5.0
hyperopt                                 0.2.7
hypertools                               0.8.0
idna                                     3.6
igraph                                   0.11.3
imagecodecs                              2024.1.1
ImageHash                                4.3.1
imageio                                  2.33.1
imbalanced-learn                         0.11.0
imgaug                                   0.4.0
importlib-metadata                       6.11.0
importlib-resources                      6.1.1
inequality                               1.0.1
iniconfig                                2.0.0
ipydatawidgets                           4.3.5
ipykernel                                6.28.0
ipyleaflet                               0.18.2
ipympl                                   0.7.0
ipython                                  8.20.0
ipython-genutils                         0.2.0
ipython-sql                              0.5.0
ipyvolume                                0.6.3
ipyvue                                   1.10.1
ipyvuetify                               1.8.10
ipywebrtc                                0.6.0
ipywidgets                               7.7.1
isoduration                              20.11.0
isort                                    5.13.2
isoweek                                  1.3.3
itsdangerous                             2.1.2
Janome                                   0.5.0
jaraco.classes                           3.3.0
jax                                      0.4.23
jax-jumpy                                1.0.0
jaxlib                                   0.4.23.dev20240116
jedi                                     0.19.1
jeepney                                  0.8.0
jieba                                    0.42.1
Jinja2                                   3.1.2
jmespath                                 1.0.1
joblib                                   1.3.2
json5                                    0.9.14
jsonpatch                                1.33
jsonpointer                              2.4
jsonschema                               4.20.0
jsonschema-specifications                2023.12.1
jupyter_client                           7.4.9
jupyter-console                          6.6.3
jupyter_core                             5.7.1
jupyter-events                           0.9.0
jupyter-http-over-ws                     0.0.8
jupyter-lsp                              1.5.1
jupyter_server                           2.12.5
jupyter_server_fileid                    0.9.1
jupyter-server-mathjax                   0.2.6
jupyter_server_proxy                     4.1.0
jupyter_server_terminals                 0.5.1
jupyter_server_ydoc                      0.8.0
jupyter-ydoc                             0.2.5
jupyterlab                               4.0.11
jupyterlab_git                           0.44.0
jupyterlab-lsp                           5.0.2
jupyterlab_pygments                      0.3.0
jupyterlab_server                        2.25.2
jupyterlab-widgets                       3.0.9
jupytext                                 1.16.0
kaggle                                   1.6.3
kaggle-environments                      1.14.3
kagglehub                                0.1.6
keras                                    2.15.0
keras-core                               0.1.7
keras-cv                                 0.8.1
keras-nlp                                0.7.0
keras-tuner                              1.4.6
kernels-mixer                            0.0.7
keyring                                  24.3.0
keyrings.google-artifactregistry-auth    1.1.2
kfp                                      2.5.0
kfp-pipeline-spec                        0.2.2
kfp-server-api                           2.0.5
kiwisolver                               1.4.5
kmapper                                  2.0.1
kmodes                                   0.12.2
korean-lunar-calendar                    0.3.1
kornia                                   0.7.1
kt-legacy                                1.0.5
kubernetes                               26.1.0
langchain                                0.1.5
langchain-community                      0.0.19
langchain-core                           0.1.21
langcodes                                3.3.0
langid                                   1.1.6
langsmith                                0.0.87
lazy_loader                              0.3
learntools                               0.3.4
leven                                    1.0.4
Levenshtein                              0.23.0
libclang                                 16.0.6
libmambapy                               1.5.0
libpysal                                 4.9.2
librosa                                  0.10.1
lightgbm                                 4.2.0
lightning-utilities                      0.10.1
lime                                     0.2.0.1
line-profiler                            4.1.2
linkify-it-py                            2.0.2
llama-index                              0.9.45.post1
llvmlite                                 0.41.1
lml                                      0.1.0
locket                                   1.0.0
loguru                                   0.7.2
LunarCalendar                            0.0.9
lxml                                     5.1.0
lz4                                      4.3.3
Mako                                     1.3.1
mamba                                    1.5.0
mapclassify                              2.6.1
marisa-trie                              1.1.0
Markdown                                 3.5.2
markdown-it-py                           3.0.0
markdownlit                              0.0.7
markovify                                0.9.4
MarkupSafe                               2.1.3
marshmallow                              3.20.2
matplotlib                               3.7.4
matplotlib-inline                        0.1.6
matplotlib-venn                          0.11.9
mccabe                                   0.7.0
mdit-py-plugins                          0.4.0
mdurl                                    0.1.2
memory-profiler                          0.61.0
menuinst                                 2.0.1
mercantile                               1.2.1
merkle-json                              1.0.0
mgwr                                     2.2.1
millify                                  0.1.1
missingno                                0.5.2
mistune                                  0.8.4
mizani                                   0.9.3
ml-dtypes                                0.2.0
mlcrate                                  0.2.0
mlens                                    0.2.3
mlxtend                                  0.23.1
mmh3                                     4.1.0
mne                                      1.6.1
mnist                                    0.2.2
mock                                     5.1.0
momepy                                   0.7.0
more-itertools                           10.2.0
mpld3                                    0.5.10
mpmath                                   1.3.0
msgpack                                  1.0.7
msgpack-numpy                            0.4.8
multidict                                6.0.4
multimethod                              1.10
multipledispatch                         1.0.0
multiprocess                             0.70.15
munch                                    4.0.0
munkres                                  1.1.4
murmurhash                               1.0.10
mypy-extensions                          1.0.0
namex                                    0.0.7
nb_conda                                 2.2.1
nb-conda-kernels                         2.3.1
nbclassic                                1.0.0
nbclient                                 0.5.13
nbconvert                                6.4.5
nbdime                                   3.2.0
nbformat                                 5.9.2
ndindex                                  1.7
nest-asyncio                             1.5.8
networkx                                 3.2.1
nibabel                                  5.2.0
nilearn                                  0.10.2
ninja                                    1.11.1.1
nltk                                     3.8.1
nose                                     1.3.7
notebook                                 6.5.4
notebook_executor                        0.2
notebook_shim                            0.2.3
numba                                    0.58.1
numexpr                                  2.8.8
numpy                                    1.24.4
nvidia-ml-py                             11.495.46
nvtx                                     0.2.8
oauth2client                             4.1.3
oauthlib                                 3.2.2
objsize                                  0.6.1
odfpy                                    1.4.1
olefile                                  0.47
onnx                                     1.15.0
openai                                   1.11.1
opencensus                               0.11.4
opencensus-context                       0.1.3
opencv-contrib-python                    4.9.0.80
opencv-python                            4.9.0.80
opencv-python-headless                   4.9.0.80
openpyxl                                 3.1.2
openslide-python                         1.3.1
opentelemetry-api                        1.22.0
opentelemetry-exporter-otlp              1.22.0
opentelemetry-exporter-otlp-proto-common 1.22.0
opentelemetry-exporter-otlp-proto-grpc   1.22.0
opentelemetry-exporter-otlp-proto-http   1.22.0
opentelemetry-proto                      1.22.0
opentelemetry-sdk                        1.22.0
opentelemetry-semantic-conventions       0.43b0
opt-einsum                               3.3.0
optax                                    0.1.8
optuna                                   3.5.0
orbax-checkpoint                         0.4.4
ordered-set                              4.1.0
orderedmultidict                         1.0.1
orjson                                   3.9.10
ortools                                  9.4.1874
osmnx                                    1.8.1
overrides                                7.4.0
packaging                                23.2
pandas                                   2.1.4
pandas-datareader                        0.10.0
pandas-profiling                         3.6.6
pandas-summary                           0.2.0
pandasql                                 0.7.3
pandocfilters                            1.5.0
panel                                    1.3.7
papermill                                2.5.0
param                                    2.0.2
parso                                    0.8.3
partd                                    1.4.1
path                                     16.9.0
path.py                                  12.5.0
pathos                                   0.3.1
pathy                                    0.10.3
patsy                                    0.5.6
pdf2image                                1.17.0
pettingzoo                               1.24.0
pexpect                                  4.8.0
phik                                     0.12.4
pickleshare                              0.7.5
Pillow                                   9.5.0
pip                                      23.3.2
pkgutil_resolve_name                     1.3.10
platformdirs                             4.1.0
plotly                                   5.18.0
plotly-express                           0.4.1
plotnine                                 0.12.4
pluggy                                   1.3.0
pointpats                                2.4.0
polars                                   0.20.5
polyglot                                 16.7.4
pooch                                    1.8.0
pox                                      0.3.3
ppca                                     0.0.4
ppft                                     1.7.6.7
preprocessing                            0.1.13
preshed                                  3.0.9
prettytable                              3.9.0
progressbar2                             4.3.2
prometheus-client                        0.19.0
promise                                  2.3
prompt-toolkit                           3.0.42
pronouncing                              0.2.0
prophet                                  1.1.1
proto-plus                               1.23.0
protobuf                                 3.20.3
psutil                                   5.9.3
ptyprocess                               0.7.0
pudb                                     2024.1
PuLP                                     2.8.0
pure-eval                                0.2.2
py-cpuinfo                               9.0.0
py-spy                                   0.3.14
py4j                                     0.10.9.7
pyaml                                    23.12.0
PyArabic                                 0.6.15
pyarrow                                  11.0.0
pyasn1                                   0.5.1
pyasn1-modules                           0.3.0
PyAstronomy                              0.20.0
pybind11                                 2.11.1
pyclipper                                1.3.0.post5
pycodestyle                              2.11.1
pycosat                                  0.6.6
pycparser                                2.21
pycryptodome                             3.20.0
pyct                                     0.5.0
pycuda                                   2024.1
pydantic                                 2.5.3
pydantic_core                            2.14.6
pydeck                                   0.8.1b0
pydegensac                               0.1.2
pydicom                                  2.4.4
pydocstyle                               6.3.0
pydot                                    1.4.2
pydub                                    0.25.1
pyemd                                    1.0.0
pyerfa                                   2.0.1.1
pyexcel-io                               0.6.6
pyexcel-ods                              0.6.0
pyfasttext                               0.4.6
pyflakes                                 3.2.0
pygltflib                                1.16.1
Pygments                                 2.17.2
PyJWT                                    2.8.0
pykalman                                 0.9.5
pyLDAvis                                 3.4.1
pylibraft                                23.8.0
pylint                                   3.0.3
pymc3                                    3.11.4
pymdown-extensions                       10.7
PyMeeus                                  0.5.12
pymongo                                  3.13.0
Pympler                                  1.0.1
pynndescent                              0.5.11
pynvml                                   11.4.1
pynvrtc                                  9.2
pyocr                                    0.8.5
pyOpenSSL                                23.3.0
pyparsing                                3.1.1
pypdf                                    4.0.0
pyproj                                   3.6.1
pysal                                    23.7
pyshp                                    2.3.1
PySocks                                  1.7.1
pytesseract                              0.3.10
pytest                                   7.4.4
python-bidi                              0.4.2
python-dateutil                          2.8.2
python-decouple                          3.8
python-dotenv                            1.0.0
python-json-logger                       2.0.7
python-Levenshtein                       0.23.0
python-louvain                           0.16
python-lsp-jsonrpc                       1.1.2
python-lsp-server                        1.10.0
python-slugify                           8.0.1
python-utils                             3.8.1
pythreejs                                2.4.2
pytoolconfig                             1.3.1
pytools                                  2023.1.1
pytorch-ignite                           0.4.13
pytorch-lightning                        2.1.3
pytz                                     2023.3.post1
pyu2f                                    0.1.5
PyUpSet                                  0.1.1.post7
pyviz_comms                              3.0.1
PyWavelets                               1.5.0
PyYAML                                   6.0.1
pyzmq                                    24.0.1
qgrid                                    1.3.1
qtconsole                                5.5.1
QtPy                                     2.4.1
quantecon                                0.7.1
quantities                               0.15.0
qudida                                   0.0.4
raft-dask                                23.8.0
rapidfuzz                                3.6.1
rasterio                                 1.3.9
rasterstats                              0.19.0
ray                                      2.9.0
ray-cpp                                  2.9.0
referencing                              0.32.1
regex                                    2023.12.25
requests                                 2.31.0
requests-oauthlib                        1.3.1
requests-toolbelt                        0.10.1
responses                                0.18.0
retrying                                 1.3.3
rfc3339-validator                        0.1.4
rfc3986-validator                        0.1.1
rgf-python                               3.12.0
rich                                     13.7.0
rich-click                               1.7.3
rmm                                      23.8.0
rope                                     1.12.0
rpds-py                                  0.16.2
rsa                                      4.9
Rtree                                    1.2.0
ruamel.yaml                              0.17.40
ruamel.yaml.clib                         0.2.7
ruamel-yaml-conda                        0.15.100
s2sphere                                 0.2.5
s3fs                                     2023.12.2
s3transfer                               0.6.2
safetensors                              0.4.2
scattertext                              0.1.19
scikit-image                             0.22.0
scikit-learn                             1.2.2
scikit-learn-intelex                     2024.1.0
scikit-multilearn                        0.2.0
scikit-optimize                          0.9.0
scikit-plot                              0.3.7
scikit-surprise                          1.1.3
scipy                                    1.11.4
seaborn                                  0.12.2
SecretStorage                            3.3.3
segment_anything                         1.0
segregation                              2.5
semver                                   3.0.2
Send2Trash                               1.8.2
sentencepiece                            0.1.99
sentry-sdk                               1.39.2
setproctitle                             1.3.3
setuptools                               69.0.3
setuptools-git                           1.2
setuptools-scm                           8.0.4
shap                                     0.44.0
Shapely                                  1.8.5.post1
shellingham                              1.5.4
Shimmy                                   1.3.0
simpervisor                              1.0.0
SimpleITK                                2.3.1
simplejson                               3.19.2
six                                      1.16.0
sklearn-pandas                           2.2.0
slicer                                   0.0.7
smart-open                               6.4.0
smhasher                                 0.150.1
smmap                                    5.0.1
sniffio                                  1.3.0
snowballstemmer                          2.2.0
snuggs                                   1.4.7
sortedcontainers                         2.4.0
soundfile                                0.12.1
soupsieve                                2.5
soxr                                     0.3.7
spacy                                    3.7.2
spacy-legacy                             3.0.12
spacy-loggers                            1.0.5
spaghetti                                1.7.4
spectral                                 0.23.1
spglm                                    1.1.0
sphinx-rtd-theme                         0.2.4
spint                                    1.0.7
splot                                    1.1.5.post1
spopt                                    0.6.0
spreg                                    1.4.2
spvcm                                    0.3.0
SQLAlchemy                               2.0.25
sqlparse                                 0.4.4
squarify                                 0.4.3
srsly                                    2.4.8
st-annotated-text                        4.0.1
stable-baselines3                        2.1.0
stack-data                               0.6.2
stanio                                   0.3.0
starlette                                0.32.0.post1
statsmodels                              0.14.1
stemming                                 1.0.1
stop-words                               2018.7.23
stopit                                   1.1.2
streamlit                                1.31.0
streamlit-aggrid                         0.3.4.post3
streamlit-camera-input-live              0.2.0
streamlit-card                           1.0.0
streamlit-embedcode                      0.1.2
streamlit-extras                         0.4.0
streamlit-faker                          0.0.3
streamlit-image-coordinates              0.1.6
streamlit-keyup                          0.2.2
streamlit-toggle-switch                  1.0.2
streamlit-vertical-slider                2.5.5
stumpy                                   1.12.0
sympy                                    1.12
tables                                   3.9.2
tabulate                                 0.9.0
tangled-up-in-unicode                    0.2.0
tbb                                      2021.11.0
tblib                                    3.0.0
tenacity                                 8.2.3
tensorboard                              2.15.1
tensorboard-data-server                  0.7.2
tensorboard-plugin-profile               2.15.0
tensorboardX                             2.6.2.2
tensorflow                               2.15.0
tensorflow-cloud                         0.1.16
tensorflow-datasets                      4.9.4
tensorflow-decision-forests              1.8.1
tensorflow-estimator                     2.15.0
tensorflow-hub                           0.15.0
tensorflow-io                            0.35.0
tensorflow-io-gcs-filesystem             0.35.0
tensorflow-metadata                      0.14.0
tensorflow-probability                   0.23.0
tensorflow-serving-api                   2.14.1
tensorflow-text                          2.15.0
tensorflow-transform                     0.14.0
tensorflowjs                             4.16.0
tensorpack                               0.11
tensorstore                              0.1.45
termcolor                                2.4.0
terminado                                0.18.0
testpath                                 0.6.0
text-unidecode                           1.3
textblob                                 0.17.1
texttable                                1.7.0
Theano                                   1.0.5
Theano-PyMC                              1.1.2
thinc                                    8.2.2
threadpoolctl                            3.2.0
tifffile                                 2023.12.9
tiktoken                                 0.5.2
timm                                     0.9.12
tinycss2                                 1.2.1
tobler                                   0.11.2
tokenizers                               0.15.1
toml                                     0.10.2
tomli                                    2.0.1
tomlkit                                  0.12.3
toolz                                    0.12.0
torch                                    2.1.2
torchaudio                               2.1.2
torchdata                                0.7.1
torchinfo                                1.8.0
torchmetrics                             1.3.0.post0
torchtext                                0.16.2
torchvision                              0.16.2
tornado                                  6.3.3
TPOT                                     0.12.1
tqdm                                     4.66.1
traceml                                  1.0.8
traitlets                                5.9.0
traittypes                               0.2.1
transformers                             4.37.0
treelite                                 3.2.0
treelite-runtime                         3.2.0
trueskill                                0.4.5
trulens_eval                             0.22.0
truststore                               0.8.0
trx-python                               0.2.9
tsfresh                                  0.20.1
typeguard                                4.1.5
typer                                    0.9.0
types-python-dateutil                    2.8.19.20240106
typing_extensions                        4.9.0
typing-inspect                           0.9.0
typing-utils                             0.1.0
tzdata                                   2023.4
tzlocal                                  5.2
uc-micro-py                              1.0.2
ucx-py                                   0.33.0
ujson                                    5.9.0
umap-learn                               0.5.5
unicodedata2                             15.1.0
Unidecode                                1.3.8
update-checker                           0.18.0
uri-template                             1.3.0
uritemplate                              3.0.1
urllib3                                  1.26.18
urwid                                    2.4.6
urwid_readline                           0.13
uvicorn                                  0.25.0
uvloop                                   0.19.0
vaex                                     4.17.0
vaex-astro                               0.9.3
vaex-core                                4.17.1
vaex-hdf5                                0.14.1
vaex-jupyter                             0.8.2
vaex-ml                                  0.18.3
vaex-server                              0.9.0
vaex-viz                                 0.5.4
validators                               0.22.0
vec_noise                                1.1.4
vecstack                                 0.4.0
virtualenv                               20.21.0
visions                                  0.7.5
vowpalwabbit                             9.9.0
vtk                                      9.3.0
Wand                                     0.6.13
wandb                                    0.16.2
wasabi                                   1.1.2
watchdog                                 4.0.0
watchfiles                               0.21.0
wavio                                    0.0.8
wcwidth                                  0.2.13
weasel                                   0.3.4
webcolors                                1.13
webencodings                             0.5.1
websocket-client                         1.7.0
websockets                               12.0
Werkzeug                                 3.0.1
wfdb                                     4.1.2
whatthepatch                             1.0.5
wheel                                    0.42.0
widgetsnbextension                       3.6.6
witwidget                                1.8.1
woodwork                                 0.27.0
wordcloud                                1.9.3
wordsegment                              1.3.1
wrapt                                    1.14.1
wurlitzer                                3.0.3
xarray                                   2024.1.0
xarray-einstats                          0.7.0
xgboost                                  2.0.3
xvfbwrapper                              0.2.9
xxhash                                   3.4.1
xyzservices                              2023.10.1
y-py                                     0.6.2
yapf                                     0.40.2
yarl                                     1.9.3
ydata-profiling                          4.6.4
yellowbrick                              1.5
ypy-websocket                            0.8.4
zict                                     3.0.0
zipp                                     3.17.0
zstandard                                0.22.0

I have this issue too, downgrading the version doesn't solve the issue.

I am also having the same issue ie RuntimeError: cannot reuse already awaited coroutine, even after downgrading to earlier version. Would be grateful if you can provide insights on how this can be addressed. Thanks. 


Hi,

I also see this issue when trying to replicate this notebook from the TruLens and LlamaIndex course from DeepLearning.ai using the latest versions of TruLens and LlamaIndex: [Notebook](https://learn.deeplearning.ai/building-evaluating-advanced-rag/lesson/2/advanced-rag-pipeline). Of course I had to import LlamaIndex libraries and adjust the class methods call to accommodate to the changes coming with v0.10.5

Here the code snippet:

```
---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
Cell In[7], line 10
      6 litellm.api_key = "NO_EVAL_KEY"
      8 tru_recorder = get_prebuilt_trulens_recorder(query_engine,
      9                                              app_id="Direct Query Engine")
---> 10 with tru_recorder as recording:
     11     for question in eval_questions:
     12         response = query_engine.query(question)

File ~/miniconda3/envs/llm-env4/lib/python3.10/site-packages/trulens_eval/app.py:842, in App.__exit__(self, exc_type, exc_value, exc_tb)
    839 self.recording_contexts.reset(ctx.token)
    841 if exc_type is not None:
--> 842     raise exc_value
    844 return

Cell In[7], line 12
     10 with tru_recorder as recording:
     11     for question in eval_questions:
---> 12         response = query_engine.query(question)
     13 records, feedback = tru.get_records_and_feedback(app_ids=[])
     14 records.head()

File ~/miniconda3/envs/llm-env4/lib/python3.10/site-packages/trulens_eval/instruments.py:633, in Instrument.tracked_method_wrapper.<locals>.tru_wrapper(*args, **kwargs)
    625 @functools.wraps(func)
    626 def tru_wrapper(*args, **kwargs):
    627     logger.debug(
    628         f"{query}: calling instrumented sync method {func} of type {type(func)}, "
    629         f"iscoroutinefunction={is_really_coroutinefunction(func)}, "
    630         f"isasyncgeneratorfunction={inspect.isasyncgenfunction(func)}"
    631     )
--> 633     return sync(tru_awrapper, *args, **kwargs)

File ~/miniconda3/envs/llm-env4/lib/python3.10/site-packages/trulens_eval/utils/asynchro.py:164, in sync(func, *args, **kwargs)
    162 # Get the return or error, return the return or raise the error.
    163 if thread.error is not None:
--> 164     raise thread.error
    165 else:
    166     return thread.ret

File ~/miniconda3/envs/llm-env4/lib/python3.10/site-packages/trulens_eval/utils/asynchro.py:152, in sync.<locals>.run_in_new_loop()
    150 try:
    151     loop = asyncio.new_event_loop()
--> 152     th.ret = loop.run_until_complete(awaitable)
    153 except Exception as e:
    154     th.error = e

File ~/miniconda3/envs/llm-env4/lib/python3.10/site-packages/nest_asyncio.py:98, in _patch_loop.<locals>.run_until_complete(self, future)
     95 if not f.done():
     96     raise RuntimeError(
     97         'Event loop stopped before Future completed.')
---> 98 return f.result()

File ~/miniconda3/envs/llm-env4/lib/python3.10/asyncio/futures.py:201, in Future.result(self)
    199 self.__log_traceback = False
    200 if self._exception is not None:
--> 201     raise self._exception.with_traceback(self._exception_tb)
    202 return self._result

File ~/miniconda3/envs/llm-env4/lib/python3.10/asyncio/tasks.py:232, in Task.__step(***failed resolving arguments***)
    228 try:
    229     if exc is None:
    230         # We use the `send` method directly, because coroutines
    231         # don't have `__iter__` and `__next__` methods.
--> 232         result = coro.send(None)
    233     else:
    234         result = coro.throw(exc)


```

@xcarlosamm @vecorro @MARUD84 @kouskouss Can you please let us know if this was fixed?

@yuvneshtruera Unfortunately, I still have the same issue "RuntimeError: cannot reuse already awaited coroutine" 

@kouskouss what version are you seeing this issue now?

@kouskouss Can you please let us know the version?

> @kouskouss Can you please let us know the version?

The problem still persists and my version is :
Name: trulens-eval
Version: 0.22.1

@kouskouss Can you please update to the latest Trulens-eval version which is 0.28.2

@kouskouss this issue is resolved by 0.28.2 - please let us know if you see otherwise.