This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import subprocess | |
def tail(filename: str) -> Generator[str, None, None]: | |
proc = subprocess.Popen(["tail", "-F", filename], stdout=subprocess.PIPE, stderr=subprocess.PIPE) | |
while True: | |
line = proc.stdout.readline() | |
if line: | |
yield line.decode("utf-8") | |
else: | |
break |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import signal | |
import asyncio | |
import logging | |
def register_graceful_shutdown(loop: asyncio.AbstractEventLoop): | |
""" Register signal handlers """ | |
for s in (signal.SIGINT, signal.SIGTERM): | |
loop.add_signal_handler(s, _signal_exit, s, loop) # pass s(signal), loop to _signal_exit | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import ssl | |
import asyncio | |
import logging | |
import weakref | |
from typing import Tuple | |
class SNIStore(ssl.SSLContext): | |
""" SSLContextContainer to store the SNI value """ |