Skip to content

Commit

Permalink
Merge pull request #4511 from RasaHQ/asyncio-callback-duration
Browse files Browse the repository at this point in the history
make slow_callback_duration a parameter in asyncio debugging
  • Loading branch information
Nikolai committed Sep 25, 2019
2 parents 02c11c9 + 9e76b38 commit 7456dc3
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,15 @@ Changed
(default behavior) or in a temporary directory by specifying the
``save_to_default_model_directory`` field in the training request.

[1.3.4]
^^^^^^^^^^^^^^^^^^^^

Fixed
-----
- asyncio warnings are now only printed if the callback takes more than 100ms
(up from 1ms)
- ``agent.load_model_from_server`` no longer affects logging

[1.3.3] - 2019-09-13
^^^^^^^^^^^^^^^^^^^^

Expand Down
3 changes: 1 addition & 2 deletions rasa/core/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
get_model,
)
from rasa.nlu.utils import is_url
from rasa.utils.common import update_sanic_log_level, set_log_level
from rasa.utils.common import update_sanic_log_level
from rasa.utils.endpoints import EndpointConfig

logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -132,7 +132,6 @@ async def _pull_model_and_fingerprint(

async with model_server.session() as session:
try:
set_log_level()
params = model_server.combine_parameters()
async with session.request(
"GET",
Expand Down
6 changes: 4 additions & 2 deletions rasa/utils/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ def configure_colored_logging(loglevel):
)


def enable_async_loop_debugging(event_loop: AbstractEventLoop) -> AbstractEventLoop:
def enable_async_loop_debugging(
event_loop: AbstractEventLoop, slow_callback_duration: float = 0.1
) -> AbstractEventLoop:
logging.info(
"Enabling coroutine debugging. Loop id {}.".format(id(asyncio.get_event_loop()))
)
Expand All @@ -49,7 +51,7 @@ def enable_async_loop_debugging(event_loop: AbstractEventLoop) -> AbstractEventL

# Make the threshold for "slow" tasks very very small for
# illustration. The default is 0.1 (= 100 milliseconds).
event_loop.slow_callback_duration = 0.001
event_loop.slow_callback_duration = slow_callback_duration

# Report all mistakes managing asynchronous resources.
warnings.simplefilter("always", ResourceWarning)
Expand Down

0 comments on commit 7456dc3

Please sign in to comment.