Skip to content

Getting this to work with FastAPI or another Async Backend #112

@waseemhnyc

Description

@waseemhnyc

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") 

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions