logtail / logtail-python

Better Stack Python client
https://betterstack.com/logs
Other
36 stars 10 forks source link

L-110 Continue flushing after shutdown until pipe is empty #17

Closed PetrHeinz closed 1 year ago

PetrHeinz commented 1 year ago

Some logs may have been left unsent on process termination. Wait with exiting the process until pipe is empty.


Tested with this block in example-project script right below logger initialization:

import threading
import time

def some_thread_function():
    print("Starting thread")
    time.sleep(1)
    for i in range(10):
        logger.debug("I am using Logtail in a thread! " + str(i))
    print("Ending thread")

t = threading.Thread(target=some_thread_function, daemon=True)
t.start()

Before suggested changes, I am using Logtail in a thread! 0 was the last message send (instead of I am using Logtail in a thread! 9)