From d13a5069e3a0e78a77bf16effe78f2ba223c495b Mon Sep 17 00:00:00 2001 From: jesopo Date: Tue, 27 Nov 2018 14:25:12 +0000 Subject: Grab response from functions asked to be executed on the main thread and feed them back to the callers, allowing rest_api.py to take the main thread while it's waiting for the response to give back to the requesting client --- modules/rest_api.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'modules/rest_api.py') diff --git a/modules/rest_api.py b/modules/rest_api.py index 28d05aed..601eebd8 100644 --- a/modules/rest_api.py +++ b/modules/rest_api.py @@ -30,9 +30,10 @@ class Handler(http.server.BaseHTTPRequestHandler): if path.startswith("/api/"): event_response = None try: - event_response = _events.on("api").on(method).on( + event_response = _bot.trigger(lambda: + _events.on("api").on(method).on( endpoint).call_unsafe_for_result(params=params, - path=args, data=data, headers=dict(self.headers)) + path=args, data=data, headers=dict(self.headers))) except Exception as e: _log.error("failed to call API endpoint \"%s\"", [path], exc_info=True) -- cgit v1.3.1-10-gc9f91