"RuntimeError: Event loop is closed During task" when ChatOllama is not a global and is not inside of function #30480
Unanswered
ChellShort
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Checked other resources
Commit to Help
Example Code
Description
I'm trying to make a RAG application where I can use a csv search to bring laptop models from a csv and semantic search to bring info of the components of those computers. But when I try to define Ollama in the "if name == "main":" and pass it through state, right at the second question of the "while" cycle, this error pops up:
File "C:\Users\iapracticante3\miniconda3\envs\Ollama_langchain\Lib\asyncio\base_events.py", line 520, in _check_closed
raise RuntimeError('Event loop is closed')
RuntimeError: Event loop is closed
During task with name 'retrieve_devices' and id '62ab0be5-0744-44ee-7103-eb6c6a86ff15'
I found two workarounds to this, first I could move the ChatOllama definition inside of the "retrieve devices" function or define it as a global variable to make it work; but honestly, I still would like to put in the main function, but I still don't know why this occurs.
System Info
Python Version: 3.11.11
Platform: Windows
Pip Freeze:
accelerate==1.5.2
aiofiles==24.1.0
aiohappyeyeballs @ file:///home/conda/feedstock_root/build_artifacts/aiohappyeyeballs_1739175731979/work
aiohttp @ file:///D:/bld/aiohttp_1738823084042/work
aiosignal @ file:///home/conda/feedstock_root/build_artifacts/aiosignal_1734342155601/work
annotated-types @ file:///home/conda/feedstock_root/build_artifacts/annotated-types_1733247046149/work
antlr4-python3-runtime==4.9.3
anyio @ file:///home/conda/feedstock_root/build_artifacts/anyio_1736174388474/work
appdirs==1.4.4
argcomplete==3.6.0
asgiref==3.8.1
asttokens @ file:///home/conda/feedstock_root/build_artifacts/asttokens_1733250440834/work
async-timeout @ file:///home/conda/feedstock_root/build_artifacts/async-timeout_1691763562544/work
attr==0.3.1
attrs @ file:///home/conda/feedstock_root/build_artifacts/attrs_1737819173731/work
azure-core==1.32.0
azure-storage-blob==12.25.0
backoff==2.2.1
bcrypt==4.2.1
beautifulsoup4==4.13.3
black==25.1.0
bleach==5.0.1
boto==2.49.0
boto3==1.37.14
botocore==1.37.14
Brotli @ file:///D:/bld/brotli-split_1725267609074/work
build==1.2.2.post1
cachetools==5.5.1
cassandra-driver==3.29.2
cassio==0.1.10
cbor==1.0.0
certifi @ file:///home/conda/feedstock_root/build_artifacts/certifi_1739515848642/work/certifi
cffi @ file:///D:/bld/cffi_1725560706917/work
chardet==5.2.0
charset-normalizer @ file:///home/conda/feedstock_root/build_artifacts/charset-normalizer_1735929714516/work
chroma-hnswlib==0.7.6
chromadb==0.6.3
click==8.1.8
cohere==5.13.12
colorama @ file:///home/conda/feedstock_root/build_artifacts/colorama_1733218098505/work
coloredlogs==15.0.1
comm @ file:///home/conda/feedstock_root/build_artifacts/comm_1733502965406/work
contourpy==1.3.1
cryptography==44.0.2
cycler==0.12.1
data==0.4
dataclasses-json==0.6.7
datamodel-code-generator==0.26.1
datasets==3.4.1
debugpy @ file:///D:/bld/debugpy_1737269744634/work
decorator @ file:///home/conda/feedstock_root/build_artifacts/decorator_1733236420667/work
defusedxml==0.7.1
Deprecated==1.2.18
deprecation==2.1.0
dill @ file:///home/conda/feedstock_root/build_artifacts/dill_1690101045195/work
distro==1.9.0
Django==5.1.7
django-annoying==0.10.6
django-cors-headers==3.6.0
django-csp==3.7
django-debug-toolbar==3.2.1
django-environ==0.10.0
django-extensions==3.2.3
django-filter==24.3
django-migration-linter==5.1.0
django-model-utils==4.1.1
django-ranged-fileresponse==0.1.2
django-rq==2.10.3
django-storages==1.12.3
django-user-agents==0.4.0
djangorestframework==3.15.2
dnspython==2.7.0
drf-dynamic-fields==0.3.0
drf-flex-fields==0.9.5
drf-generators==0.3.0
duckduckgo_search==7.5.2
durationpy==0.9
effdet==0.4.1
einops==0.8.1
email_validator==2.2.0
emoji==2.14.1
et_xmlfile==2.0.0
eval_type_backport==0.2.2
exceptiongroup @ file:///home/conda/feedstock_root/build_artifacts/exceptiongroup_1733208806608/work
executing @ file:///home/conda/feedstock_root/build_artifacts/executing_1733569351617/work
expiringdict==1.2.2
faiss-cpu==1.10.0
Faker==37.0.0
fastapi==0.115.8
fastavro==1.10.0
ffmpy==0.5.0
filelock==3.13.1
filetype==1.2.0
FlagEmbedding==1.3.4
flatbuffers==25.2.10
fonttools==4.56.0
frozenlist @ file:///D:/bld/frozenlist_1737645258591/work
fsspec==2024.6.1
funcsigs==1.0.2
future==1.0.0
genson==1.3.0
geomet==0.2.1.post1
gitdb==4.0.12
GitPython==3.1.44
google==3.0.0
google-api-core==2.24.2
google-auth==2.38.0
google-cloud-appengine-logging==1.6.1
google-cloud-audit-log==0.3.2
google-cloud-core==2.4.3
google-cloud-logging==3.11.4
google-cloud-storage==2.19.0
google-cloud-vision==3.10.1
google-crc32c==1.7.0
google-resumable-media==2.7.2
google_search_results==2.4.2
googleapis-common-protos==1.67.0
gotrue==2.11.4
gradio==5.20.1
gradio_client==1.7.2
greenlet @ file:///D:/bld/greenlet_1734532814363/work
gritql==0.1.5
groovy==0.1.2
grpc-google-iam-v1==0.14.2
grpcio==1.67.1
grpcio-status==1.71.0
grpcio-tools==1.70.0
h11 @ file:///home/conda/feedstock_root/build_artifacts/h11_1733327467879/work
h2 @ file:///home/conda/feedstock_root/build_artifacts/h2_1738578511449/work
hpack @ file:///home/conda/feedstock_root/build_artifacts/hpack_1737618293087/work
html5lib==1.1
httpcore @ file:///home/conda/feedstock_root/build_artifacts/bld/rattler-build_httpcore_1731707562/work
httptools==0.6.4
httpx @ file:///home/conda/feedstock_root/build_artifacts/httpx_1733663348460/work
httpx-sse==0.4.0
huggingface_hub @ file:///home/conda/feedstock_root/build_artifacts/huggingface_hub_1739988688175/work
humanfriendly==10.0
humansignal-drf-yasg==1.21.10.post1
hyperframe @ file:///home/conda/feedstock_root/build_artifacts/hyperframe_1737618333194/work
idna @ file:///home/conda/feedstock_root/build_artifacts/idna_1733211830134/work
ijson==3.3.0
importlib_metadata==8.5.0
importlib_resources==6.5.2
inflect==5.6.2
inflection==0.5.1
inquirerpy==0.3.4
inscriptis==2.6.0
ipykernel @ file:///D:/bld/ipykernel_1719845595208/work
ipython @ file:///D:/bld/bld/rattler-build_ipython_1738421304/work
ir_datasets==0.5.10
isodate==0.7.2
isort==5.13.2
jedi @ file:///home/conda/feedstock_root/build_artifacts/jedi_1733300866624/work
Jinja2==3.1.4
jiter==0.8.2
jmespath==1.0.1
joblib @ file:///home/conda/feedstock_root/build_artifacts/joblib_1733736026804/work
jsf==0.11.2
jsonpatch @ file:///home/conda/feedstock_root/build_artifacts/jsonpatch_1733814567314/work
jsonpointer @ file:///D:/bld/jsonpointer_1725302960531/work
jsonschema==4.23.0
jsonschema-specifications==2024.10.1
jupyter_client @ file:///home/conda/feedstock_root/build_artifacts/jupyter_client_1733440914442/work
jupyter_core @ file:///D:/bld/jupyter_core_1727163532151/work
keyboard==0.13.5
kiwisolver==1.4.8
kubernetes==32.0.1
label-studio==1.16.0
label-studio-sdk==1.0.10
langchain==0.3.21
langchain-chroma==0.2.2
langchain-cli==0.0.35
langchain-community==0.3.20
langchain-core==0.3.46
langchain-huggingface==0.1.2
langchain-ollama==0.2.3
langchain-text-splitters==0.3.7
langdetect==1.0.9
langgraph==0.3.5
langgraph-checkpoint==2.0.18
langgraph-prebuilt==0.1.2
langgraph-sdk==0.1.55
langserve==0.3.1
langsmith @ file:///home/conda/feedstock_root/build_artifacts/langsmith_1737099297406/work
lark==1.2.2
launchdarkly-server-sdk==8.2.1
lockfile==0.12.2
lxml==5.3.1
lxml_html_clean==0.4.1
lz4==4.4.3
markdown-it-py==3.0.0
MarkupSafe==2.1.5
marshmallow==3.26.1
matplotlib==3.10.1
matplotlib-inline @ file:///home/conda/feedstock_root/build_artifacts/matplotlib-inline_1733416936468/work
mdurl==0.1.2
mmh3==5.1.0
monotonic==1.6
mpmath @ file:///home/conda/feedstock_root/build_artifacts/mpmath_1733302684489/work
msgpack==1.1.0
multidict @ file:///D:/bld/multidict_1729065636540/work
multiprocess @ file:///D:/bld/multiprocess_1695458970146/work
mypy-extensions==1.0.0
nest_asyncio @ file:///home/conda/feedstock_root/build_artifacts/nest-asyncio_1733325553580/work
networkx==3.3
nltk==3.9.1
numpy @ file:///D:/bld/numpy_1707225528937/work/dist/numpy-1.26.4-cp311-cp311-win_amd64.whl#sha256=537f0573fefb1e93b3633e8a79102e6b6d2911e09e0a90008993efef4242448e
oauthlib==3.2.2
olefile==0.47
ollama==0.4.7
omegaconf==2.3.0
onnx==1.17.0
onnxruntime==1.20.1
openai==1.64.0
opencv-python==4.11.0.86
openpyxl==3.1.5
opentelemetry-api==1.30.0
opentelemetry-exporter-otlp-proto-common==1.30.0
opentelemetry-exporter-otlp-proto-grpc==1.30.0
opentelemetry-instrumentation==0.51b0
opentelemetry-instrumentation-asgi==0.51b0
opentelemetry-instrumentation-fastapi==0.51b0
opentelemetry-proto==1.30.0
opentelemetry-sdk==1.30.0
opentelemetry-semantic-conventions==0.51b0
opentelemetry-util-http==0.51b0
optree @ file:///D:/bld/optree_1737742737309/work
ordered-set==4.0.2
orjson @ file:///D:/bld/orjson_1737229069192/work
overrides==7.7.0
packaging @ file:///home/conda/feedstock_root/build_artifacts/packaging_1733203243479/work
pandas @ file:///D:/bld/pandas_1726878554493/work
parso @ file:///home/conda/feedstock_root/build_artifacts/parso_1733271261340/work
pathspec==0.12.1
pdf2image==1.17.0
pdfkit==1.0.0
pdfminer.six==20240706
peft==0.15.0
pfzy==0.3.4
pi_heif==0.22.0
pickleshare @ file:///home/conda/feedstock_root/build_artifacts/pickleshare_1733327343728/work
pikepdf==9.5.2
pillow==11.0.0
platformdirs @ file:///home/conda/feedstock_root/build_artifacts/platformdirs_1733232627818/work
portalocker==2.10.1
postgrest==0.19.3
posthog==3.14.2
primp==0.14.0
prompt_toolkit @ file:///home/conda/feedstock_root/build_artifacts/prompt-toolkit_1737453357274/work
propcache @ file:///D:/bld/propcache_1737635564183/work
proto-plus==1.26.1
protobuf==5.29.3
psutil @ file:///D:/bld/psutil_1735327360263/work
psycopg2-binary==2.9.10
pure_eval @ file:///home/conda/feedstock_root/build_artifacts/pure_eval_1733569405015/work
pyarrow==19.0.1
pyasn1==0.6.1
pyasn1_modules==0.4.1
pybind11 @ file:///D:/bld/pybind11-split_1730237329882/work
pybind11_global @ file:///D:/bld/pybind11-split_1730237329882/work
pyboxen==1.3.0
pycocotools==2.0.8
pycparser @ file:///home/conda/feedstock_root/build_artifacts/bld/rattler-build_pycparser_1733195786/work
pydantic @ file:///home/conda/feedstock_root/build_artifacts/pydantic_1737761369378/work
pydantic-settings==2.7.1
pydantic_core @ file:///D:/bld/pydantic-core_1734571360609/work
pydub==0.25.1
Pygments @ file:///home/conda/feedstock_root/build_artifacts/pygments_1736243443484/work
pymilvus==2.5.6
pymilvus.model==0.3.1
pyparsing==3.2.1
pypdf==5.4.0
pypdfium2==4.30.1
PyPika==0.48.9
pyproject_hooks==1.2.0
pyreadline3==3.5.4
pyRFC3339==2.0.1
PySocks @ file:///D:/bld/pysocks_1733217287171/work
python-dateutil @ file:///home/conda/feedstock_root/build_artifacts/python-dateutil_1733215673016/work
python-dotenv==1.0.1
python-iso639==2025.2.18
python-json-logger==2.0.4
python-magic==0.4.27
python-multipart==0.0.20
python-oxmsg==0.0.2
pytz==2022.7.1
pywin32==307
PyYAML @ file:///D:/bld/pyyaml_1737454660454/work
pyzmq @ file:///D:/bld/pyzmq_1738270978316/work
qdrant-client==1.13.2
rank-bm25==0.2.2
RapidFuzz==3.12.2
realtime==2.4.0
redis==5.2.1
referencing==0.36.2
regex @ file:///D:/bld/regex_1730952204165/work
requests @ file:///home/conda/feedstock_root/build_artifacts/requests_1733217035951/work
requests-file==2.1.0
requests-mock==1.12.1
requests-oauthlib==2.0.0
requests-toolbelt @ file:///home/conda/feedstock_root/build_artifacts/requests-toolbelt_1733734787568/work
rich==13.9.4
rpds-py==0.23.1
rq==1.16.2
rsa==4.9
rstr==3.2.2
ruff==0.9.9
rules==3.4
s3transfer==0.11.4
safehttpx==0.1.6
safetensors @ file:///D:/bld/safetensors_1736382957946/work
scikit-learn @ file:///D:/bld/scikit-learn_1736496780928/work/dist/scikit_learn-1.6.1-cp311-cp311-win_amd64.whl#sha256=b8f37c282c66c737a09228918d0bfcadafb9f1d4bfb1dc6289040870d453703b
scipy @ file:///C:/bld/scipy-split_1739790799455/work/dist/scipy-1.15.2-cp311-cp311-win_amd64.whl#sha256=7d4ec4c2c958f31576b5ea44433874f567d6f5e65bfcde22e2d960ac86b80515
semantic-version==2.10.0
semver==3.0.4
sentence-transformers @ file:///home/conda/feedstock_root/build_artifacts/sentence-transformers_1738211130290/work
sentencepiece==0.2.0
sentry-sdk==2.23.1
shellingham==1.5.4
six @ file:///home/conda/feedstock_root/build_artifacts/six_1733380938961/work
smart-open==7.1.0
smmap==5.0.2
sniffio @ file:///home/conda/feedstock_root/build_artifacts/sniffio_1733244044561/work
soupsieve==2.6
SQLAlchemy @ file:///D:/bld/sqlalchemy_1738913156613/work
sqlparse==0.5.3
sse-starlette==1.8.2
stack_data @ file:///home/conda/feedstock_root/build_artifacts/stack_data_1733569443808/work
starlette==0.45.3
storage3==0.11.3
StrEnum==0.4.15
supabase==2.13.0
supafunc==0.9.3
sympy==1.13.1
tabulate==0.9.0
tenacity @ file:///home/conda/feedstock_root/build_artifacts/tenacity_1733649050774/work
threadpoolctl @ file:///home/conda/feedstock_root/build_artifacts/threadpoolctl_1714400101435/work
tiktoken==0.9.0
timm==1.0.15
tldextract==5.1.3
tokenizers @ file:///D:/bld/tokenizers_1732733984122/work/bindings/python
toml==0.10.2
tomlkit==0.13.2
torch==2.6.0+cu124
torchaudio==2.6.0+cu124
torchvision==0.21.0+cu124
tornado @ file:///D:/bld/tornado_1732615900055/work
tqdm @ file:///home/conda/feedstock_root/build_artifacts/tqdm_1735661334605/work
traitlets @ file:///home/conda/feedstock_root/build_artifacts/traitlets_1733367359838/work
transformers @ file:///home/conda/feedstock_root/build_artifacts/transformers_1739826231190/work
trec-car-tools==2.6
typer==0.15.2
types-requests==2.32.0.20241016
typing-inspect==0.9.0
typing-inspection==0.4.0
typing_extensions @ file:///home/conda/feedstock_root/build_artifacts/typing_extensions_1733188668063/work
tzdata @ file:///home/conda/feedstock_root/build_artifacts/python-tzdata_1737541069190/work
ua-parser==1.0.1
ua-parser-builtins==0.18.0.post1
ujson==5.10.0
unlzw3==0.2.3
unstructured==0.17.2
unstructured-client==0.31.3
unstructured-inference==0.8.10
unstructured.pytesseract==0.3.15
uritemplate==4.1.1
urllib3==1.26.20
user-agents==2.2.0
uvicorn==0.34.0
warc3-wet==0.2.5
warc3-wet-clueweb09==0.2.5
watchfiles==1.0.4
wcwidth @ file:///home/conda/feedstock_root/build_artifacts/wcwidth_1733231326287/work
webencodings==0.5.1
websocket-client==1.8.0
websockets==14.2
wikipedia==1.4.0
win_inet_pton @ file:///D:/bld/win_inet_pton_1733130564612/work
wrapt==1.17.2
xmljson==0.2.1
xxhash @ file:///D:/bld/python-xxhash_1725272140818/work
yarl @ file:///D:/bld/yarl_1737575828275/work
zipp @ file:///home/conda/feedstock_root/build_artifacts/zipp_1732827521216/work
zlib-state==0.1.9
zstandard==0.23.0
Beta Was this translation helpful? Give feedback.
All reactions