We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
sleep 50 milliseconds when the queue is empty, will reduce CPU usage by 3%.
class Logger: LOGGERS = [] def __init__(self): self.run = True self.loggers = { logger: logging.getLogger(logger) for logger in self.LOGGERS } def __call__(self, queue) -> None: signal_func(SIGINT, self.stop) signal_func(SIGTERM, self.stop) while self.run: try: record: LogRecord = queue.get_nowait() except Empty: time.sleep(0.05) #### can reduce CPU usage continue logger = self.loggers.get(record.name) logger.handle(record)
The text was updated successfully, but these errors were encountered:
I thought we added something like that 🤔
If not, can you add a PR?
Sorry, something went wrong.
I think change queue.get_nowait() to queue.get(timeout=0.05) is better.
queue.get_nowait()
queue.get(timeout=0.05)
Fix sanic-org#202: reduce CPU in logging
03dc8e9
203edbb
No branches or pull requests
sleep 50 milliseconds when the queue is empty, will reduce CPU usage by 3%.
The text was updated successfully, but these errors were encountered: