I have put together a Dash application that has two callbacks which do the following, respectively
- Update raw data on a weekly schedule using a dcc.Interval component by extracting data from SQL and saving it into a Div for the other callback to use. This process usually takes a while so I designed the application to run this separately from the next callback.
- Run an XGBoost model on the data loaded from the Div.
However, I am getting the error “RuntimeError: There is no current event loop in thread ‘Thread-24’.”, which upon inspecting the traceback below, appears to be related to XGBoost’s multithreading.
Traceback (most recent call last):
File "C:\Users\VictorBlancada\Anaconda3\lib\site-packages\tornado\ioloop.py", line 271, in current
return IOLoop._ioloop_for_asyncio[loop]
KeyError: <_WindowsSelectorEventLoop running=False closed=False debug=False>
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\VictorBlancada\Anaconda3\lib\site-packages\xgboost\compat.py", line 181, in <module>
from dask.distributed import Client, get_client
File "C:\Users\VictorBlancada\Anaconda3\lib\site-packages\dask\distributed.py", line 3, in <module>
from distributed import *
File "C:\Users\VictorBlancada\Anaconda3\lib\site-packages\distributed\__init__.py", line 3, in <module>
from .actor import Actor, ActorFuture
File "C:\Users\VictorBlancada\Anaconda3\lib\site-packages\distributed\actor.py", line 6, in <module>
from .client import Future, default_client
File "C:\Users\VictorBlancada\Anaconda3\lib\site-packages\distributed\client.py", line 44, in <module>
from .batched import BatchedSend
File "C:\Users\VictorBlancada\Anaconda3\lib\site-packages\distributed\batched.py", line 8, in <module>
from .core import CommClosedError
File "C:\Users\VictorBlancada\Anaconda3\lib\site-packages\distributed\core.py", line 17, in <module>
from .comm import (
File "C:\Users\VictorBlancada\Anaconda3\lib\site-packages\distributed\comm\__init__.py", line 25, in <module>
_register_transports()
File "C:\Users\VictorBlancada\Anaconda3\lib\site-packages\distributed\comm\__init__.py", line 17, in _register_transports
from . import tcp
File "C:\Users\VictorBlancada\Anaconda3\lib\site-packages\distributed\comm\tcp.py", line 337, in <module>
class BaseTCPConnector(Connector, RequireEncryptionMixin):
File "C:\Users\VictorBlancada\Anaconda3\lib\site-packages\distributed\comm\tcp.py", line 339, in BaseTCPConnector
_resolver = netutil.ExecutorResolver(close_executor=False, executor=_executor)
File "C:\Users\VictorBlancada\Anaconda3\lib\site-packages\tornado\util.py", line 286, in __new__
instance.initialize(*args, **init_kwargs)
File "C:\Users\VictorBlancada\Anaconda3\lib\site-packages\tornado\netutil.py", line 422, in initialize
self.io_loop = IOLoop.current()
File "C:\Users\VictorBlancada\Anaconda3\lib\site-packages\tornado\ioloop.py", line 276, in current
current = AsyncIOMainLoop(make_current=True) # type: Optional[IOLoop]
File "C:\Users\VictorBlancada\Anaconda3\lib\site-packages\tornado\util.py", line 286, in __new__
instance.initialize(*args, **init_kwargs)
File "C:\Users\VictorBlancada\Anaconda3\lib\site-packages\tornado\platform\asyncio.py", line 228, in initialize
super(AsyncIOMainLoop, self).initialize(asyncio.get_event_loop(), **kwargs)
File "C:\Users\VictorBlancada\Anaconda3\lib\asyncio\events.py", line 644, in get_event_loop
% threading.current_thread().name)
RuntimeError: There is no current event loop in thread 'Thread-24'.
Has anyone else encountered this?