RuntimeError: There is no current event loop in thread 'ScriptRunner.scriptThread' while importing Dask Gateway

we are trying to use dask cluster inside the Streamlit Application but we are getting this error , Can you please guide how we can resolve this error .

Dask Gateway Version - 0.9.0

In app.py if we will put single line “from dask_gateway import Gateway” then its started giving the errors

2022-04-12 17:30:37.216 Traceback (most recent call last):
  File "c:\users\akash.goel1\appdata\local\programs\python\python38\lib\site-packages\streamlit\scriptrunner\script_runner.py", line 443, in _run_script
    exec(code, module.__dict__)
  File "C:\Users\Akash.Goel1\Downloads\Medium-Blogs-master\streamlitBlog\app.py", line 2, in <module>
    from dask_gateway import Gateway
  File "c:\users\akash.goel1\appdata\local\programs\python\python38\lib\site-packages\dask_gateway\__init__.py", line 2, in <module>
    from .client import (
  File "c:\users\akash.goel1\appdata\local\programs\python\python38\lib\site-packages\dask_gateway\client.py", line 18, in <module>
    from distributed import Client
  File "c:\users\akash.goel1\appdata\local\programs\python\python38\lib\site-packages\distributed\__init__.py", line 7, in <module>
    from .actor import Actor, ActorFuture
  File "c:\users\akash.goel1\appdata\local\programs\python\python38\lib\site-packages\distributed\actor.py", line 5, in <module>
    from .client import Future
  File "c:\users\akash.goel1\appdata\local\programs\python\python38\lib\site-packages\distributed\client.py", line 59, in <module>
    from .batched import BatchedSend
  File "c:\users\akash.goel1\appdata\local\programs\python\python38\lib\site-packages\distributed\batched.py", line 10, in <module>
    from .core import CommClosedError
  File "c:\users\akash.goel1\appdata\local\programs\python\python38\lib\site-packages\distributed\core.py", line 28, in <module>
    from .comm import (
  File "c:\users\akash.goel1\appdata\local\programs\python\python38\lib\site-packages\distributed\comm\__init__.py", line 25, in <module>
    _register_transports()
  File "c:\users\akash.goel1\appdata\local\programs\python\python38\lib\site-packages\distributed\comm\__init__.py", line 17, in _register_transports
    from . import inproc, tcp, ws
  File "c:\users\akash.goel1\appdata\local\programs\python\python38\lib\site-packages\distributed\comm\tcp.py", line 387, in <module>
    class BaseTCPConnector(Connector, RequireEncryptionMixin):
  File "c:\users\akash.goel1\appdata\local\programs\python\python38\lib\site-packages\distributed\comm\tcp.py", line 389, in BaseTCPConnector
    _resolver = netutil.ExecutorResolver(close_executor=False, executor=_executor)
  File "c:\users\akash.goel1\appdata\local\programs\python\python38\lib\site-packages\tornado\util.py", line 288, in __new__
    instance.initialize(*args, **init_kwargs)
  File "c:\users\akash.goel1\appdata\local\programs\python\python38\lib\site-packages\tornado\netutil.py", line 427, in initialize
    self.io_loop = IOLoop.current()
  File "c:\users\akash.goel1\appdata\local\programs\python\python38\lib\site-packages\tornado\ioloop.py", line 263, in current
    loop = asyncio.get_event_loop()
  File "c:\users\akash.goel1\appdata\local\programs\python\python38\lib\asyncio\events.py", line 639, in get_event_loop
    raise RuntimeError('There is no current event loop in thread %r.'
RuntimeError: There is no current event loop in thread 'ScriptRunner.scriptThread'.

@akash-goel Welcome to Discourse and thanks for this question! I’m not sure what’s causing this error, but maybe something in this blog can help: Effective Data Storytelling for Larger-Than-Memory Datasets with Streamlit, Dask, and Coiled : Coiled

I’d also encourage you to share this question on the dask-gateway issue tracker to reach the maintainers directly. If you do so, please include the version of dask and distributed you’re running!