Skip to content

Commit

Permalink
fix: Fix for Windows ProactorEventLoop
Browse files Browse the repository at this point in the history
  • Loading branch information
Animesh404 committed Jan 7, 2025
1 parent e782243 commit da8b81b
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 6 deletions.
17 changes: 15 additions & 2 deletions openadapt/app/tray.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,28 @@
usage: `python -m openadapt.app.tray` or `poetry run app`
"""

import sys
import asyncio
import os

# Fix for Windows ProactorEventLoop
if sys.platform == "win32":
try:
if isinstance(
asyncio.get_event_loop_policy(), asyncio.WindowsProactorEventLoopPolicy
):
# Use WindowsSelectorEventLoopPolicy instead
asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy())
except Exception as e:
print(f"Failed to set event loop policy: {e}")

from datetime import datetime
from functools import partial
from pprint import pformat
from threading import Event, Thread
from typing import Any, Callable
import inspect
import multiprocessing
import os
import sys
import time

from pyqttoast import Toast, ToastButtonAlignment, ToastIcon, ToastPosition, ToastPreset
Expand Down
12 changes: 8 additions & 4 deletions openadapt/entrypoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,39 +43,43 @@ def start_loading_sequence(self) -> None:

# Configuration - 20%
try:
self.progress_updated.emit(20, "Loading configuration...")

from openadapt.config import print_config

self.progress_updated.emit(20, "Loading configuration...")
print_config()
except Exception as e:
logger.error(f"Configuration error: {e}")
return False

# Error reporting setup - 40%
try:
self.progress_updated.emit(40, "Configuring error reporting...")

from openadapt.error_reporting import configure_error_reporting

self.progress_updated.emit(40, "Configuring error reporting...")
configure_error_reporting()
except Exception as e:
logger.error(f"Error reporting setup failed: {e}")
return False

# Database context - 60%
try:
self.progress_updated.emit(60, "Loading database context...")

from openadapt.alembic.context_loader import load_alembic_context

load_alembic_context()
self.progress_updated.emit(60, "Loading database context...")
except Exception as e:
logger.error(f"Database context loading failed: {e}")
return False

# System tray setup - 80%
try:
self.progress_updated.emit(80, "Setting up system tray...")

from openadapt.app import tray

self.progress_updated.emit(80, "Setting up system tray...")
tray_instance = tray.SystemTrayIcon(app=self.app)

except Exception as e:
Expand Down

0 comments on commit da8b81b

Please sign in to comment.