Asyncio - Task exception was never retrieved error RASA 2.1.0

I’ve been getting this error when calling a specific action at the end of the conversation:

ERROR    asyncio  - Task exception was never retrieved
future: <Task finished coro=<configure_app.<locals>.run_cmdline_io() done, defined at c:\users\fredd\appdata\local\programs\python\python37\lib\site-packages\rasa\core\> exception=TimeoutError()>
Traceback (most recent call last):
  File "c:\users\fredd\appdata\local\programs\python\python37\lib\site-packages\rasa\core\", line 138, in run_cmdline_io
  File "c:\users\fredd\appdata\local\programs\python\python37\lib\site-packages\rasa\core\channels\", line 182, in record_messages
    async for response in bot_responses:
  File "c:\users\fredd\appdata\local\programs\python\python37\lib\site-packages\rasa\core\channels\", line 137, in send_message_receive_stream
    async for line in resp.content:
  File "c:\users\fredd\appdata\local\programs\python\python37\lib\site-packages\aiohttp\", line 39, in __anext__
    rv = await self.read_func()
  File "c:\users\fredd\appdata\local\programs\python\python37\lib\site-packages\aiohttp\", line 328, in readline
    await self._wait('readline')
  File "c:\users\fredd\appdata\local\programs\python\python37\lib\site-packages\aiohttp\", line 296, in _wait
    await waiter
  File "c:\users\fredd\appdata\local\programs\python\python37\lib\site-packages\aiohttp\", line 596, in __exit__
    raise asyncio.TimeoutError from None
Transport closed @ ('', 59644) and exception experienced during error handling

The action uses a custom machine learning model I have made in another file and am calling to classify as user’s response, where CodeTypeClassifier and TextPreprocessor are both custom classes I’ve written. All this does is run a slot value through a model which is loaded from file, so the action itself takes ~10s to run:

class ClassifyCodeType(Action):

    def name(self) -> Text:
        return "action_classify_code_type"

    def run(
            tracker: Tracker,
            domain: "DomainDict",
        """Takes the describe_dispute slot and runs it through a pretrained ML classifier to classify it as a Code Type
           Output and confidence is then saved to a slot each"""

        model_directory = xxxx
        vectorizer_directory = xxxx
        encoder_directory = xxxx

        # Instantiating class objects
        codeType_classifier = CodeTypeClassifier(RANDOM_STATE=54,
        text_processor = TextPreprocessor(text_attribute=None, data_type='list')

        # Model is trained against the free-text slot so need to grab that
        user_input = tracker.get_slot("describe_dispute")

        # Perform the same cleaning to the user_input variable as was done during training
        _user_input = text_processor.transform([user_input])

        # Get the probability and classification from the ML model
        prediction_probability, prediction = codeType_classifier.predict_on_user_input(user_input=_user_input,

        print(f"Predicted class: {''.join(prediction)}, with probability: {np.amax(prediction_probability)}")

        return [SlotSet("code_type", ''.join(prediction)), SlotSet("code_probability_score", np.amax(prediction_probability))]

I’m not totally convinced that the action itself is the problem as the print statement can be seen in the action server, and the action server doesn’t crash after the above message appears in the shell:

I have seen other topics similar to this that suggest a fresh rasa install which I have tried, to no success.


RASA: 2.1.0

rasa_sdk: 2.2.0

1 Like

I’ve managed to solve this thanks to this comment.

As the action sometimes took > 10s to run I had to change the value of:


to ~20s in ..\AppData\Local\Programs\Python\Python37\Lib\site-packages\rasa\core\channels which ended up working perfectly

1 Like

Thanks a lot. It worked. But I had to set it to 90, even 30 wasn’t working

where to find this sir??


track down from your error message that the appdata can be found in the hidden folders, for my case


then open change the:

DEFAULT_STREAM_READING_TIMEOUT_IN_SECONDS = 10 —> 20 for my case it works