From 47ea5db7c6df048d9bf05558added20da8fe4418 Mon Sep 17 00:00:00 2001 From: fdev31 Date: Fri, 28 Jul 2023 21:55:02 +0200 Subject: [PATCH] Add retry in daemon --- pyprland/command.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/pyprland/command.py b/pyprland/command.py index f61ac97..9109570 100755 --- a/pyprland/command.py +++ b/pyprland/command.py @@ -4,6 +4,7 @@ import json import sys import os import importlib +import itertools import traceback @@ -113,8 +114,16 @@ class Pyprland: async def run_daemon(): manager = Pyprland() + err_count = itertools.count() manager.server = await asyncio.start_unix_server(manager.read_command, CONTROL) - events_reader, events_writer = await get_event_stream() + try: + events_reader, events_writer = await get_event_stream() + except Exception as e: + print("Failed to get event stream: %s" % e) + if next(err_count) > 10: + raise + await asyncio.sleep(1) + manager.event_reader = events_reader try: