Skip to content

Commit

Permalink
Added stack trace
Browse files Browse the repository at this point in the history
Added stack trace to log in case of i/o events inside event loop.
  • Loading branch information
vlebourl committed Jun 16, 2020
1 parent 02b1c5f commit f6aa841
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions custom_components/tahoma/tahoma_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,17 @@
"""

import json
import logging
import pprint
import requests
import traceback
import urllib.parse

BASE_URL = 'https://tahomalink.com/enduser-mobile-web/enduserAPI/' # /doc for API doc
BASE_HEADERS = {'User-Agent': 'mine'}

_LOGGER = logging.getLogger(__name__)


class TahomaApi:
"""Connection to TaHoma API."""
Expand Down Expand Up @@ -86,6 +91,11 @@ def send_request(self, method, url: str, headers, data=None, timeout: int = 10,
if not self.__logged_in:
self.login()

stack = pprint.pformat(traceback.extract_stack())
if "asyncio" in stack:
_LOGGER.warning(
"I/O stack trace:\n"+stack
)
request = method(url, headers=headers, data=data, timeout=timeout)
if request.status_code == 200:
try:
Expand Down

0 comments on commit f6aa841

Please sign in to comment.