python icon indicating copy to clipboard operation
python copied to clipboard

Getting this to work with FastAPI or another Async Backend

Open waseemhnyc opened this issue 1 year ago • 1 comments

When attempting to do this in my FastAPI backend. I am noticing that the request is getting blocked.

    handler = LogDNAHandler(key='')
    logging.getLogger().addHandler(handler)
    logging.info("Checking to see if it works!")

Looking at the library. I included the print "Request Sent". It never gets printed, the request does not execute, the backend sits there and I need to restart the entire app.

        try:
            headers = {
                'user-agent': self.user_agent,
                'apikey': self.key
            }
            response = requests.post(url=self.url,
                                     json=data,
                                     params={
                                         'hostname': self.hostname,
                                         'ip': self.ip,
                                         'mac': self.mac,
                                         'tags': self.tags,
                                         'now': int(time.time() * 1000)
                                     },
                                     stream=True,
                                     allow_redirects=True,
                                     timeout=self.request_timeout,
                                     headers=headers)
            print("Request Sent") 

waseemhnyc avatar May 24 '24 14:05 waseemhnyc

See https://github.com/logdna/python/pull/114

YoussefHenna avatar Jun 23 '25 16:06 YoussefHenna