Skip to content

Commit 20d7965

Browse files
committed
Use dedicated eventloops
1 parent 44a8f89 commit 20d7965

File tree

2 files changed

+17
-13
lines changed

2 files changed

+17
-13
lines changed

main.py

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import contextlib
44
import os
55
import pathlib
6-
import subprocess
76
import sys
87

98
version = "11.1"
@@ -28,20 +27,13 @@ def main():
2827
from modules import globals
2928

3029
from common.structs import Os
31-
try:
32-
# Install uvloop on Linux and Rubicon-ObjC on MacOS, non essential so ignore errors
33-
if globals.os is Os.Linux:
34-
# Faster eventloop
30+
if globals.os is not Os.Windows:
31+
# Faster eventloop, non essential so ignore errors
32+
try:
3533
import uvloop
3634
asyncio.set_event_loop_policy(uvloop.EventLoopPolicy())
37-
# Disable coredumps, desktop-notifier with uvloop segfaults at app exit
38-
subprocess.Popen(["prlimit", "--core=0", "--pid", str(os.getpid())])
39-
elif globals.os is Os.MacOS:
40-
# Needed for desktop-notifier
41-
import rubicon.objc.eventloop as crloop
42-
asyncio.set_event_loop_policy(crloop.EventLoopPolicy())
43-
except Exception:
44-
pass
35+
except Exception:
36+
pass
4537

4638
from external import async_thread, sync_thread
4739
async_thread.setup()

modules/notification_proc.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,4 +161,16 @@ async def _daemon(icon_uri: str):
161161

162162

163163
def daemon(*args, **kwargs):
164+
if sys.platform.startswith("linux"):
165+
# Faster eventloop, non essential so ignore errors
166+
try:
167+
import uvloop
168+
asyncio.set_event_loop_policy(uvloop.EventLoopPolicy())
169+
except Exception:
170+
pass
171+
elif sys.platform.startswith("darwin"):
172+
# Needed for desktop-notifier on MacOS
173+
import rubicon.objc.eventloop as cfloop
174+
asyncio.set_event_loop_policy(cfloop.EventLoopPolicy())
175+
164176
asyncio.run(_daemon(*args, **kwargs))

0 commit comments

Comments
 (0)