Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ dynamic = ["version"]

dependencies = [
"pythonnet>=3.0.1",
"pythoncom>=308; os_name == 'nt'",
]

[project.optional-dependencies]
Expand Down
15 changes: 14 additions & 1 deletion src/pyrenode3/inits.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import atexit
import time
from threading import Thread
import os
if os.name == "nt"
import pythoncom

from Antmicro.Renode import Emulator
from Antmicro.Renode.Analyzers import LoggingUartAnalyzer
Expand Down Expand Up @@ -46,6 +49,16 @@ def __clean(self):
c()


def start_main_thread():
""" start ExecuteAsMainThread """
if os.name == "nt":
pythoncom.CoInitializeEx(pythoncom.COINIT_APARTMENTTHREADED)
Emulator.ExecuteAsMainThread()
pythoncom.CoUninitialize()
else:
Emulator.ExecuteAsMainThread()


class EmulatorInit(metaclass=MetaSingleton):
"""A class used for initializing the emulator."""

Expand All @@ -54,7 +67,7 @@ def __init__(self):

Emulator.ShowAnalyzers = True

self.__thread = Thread(target=Emulator.ExecuteAsMainThread, daemon=True)
self.__thread = Thread(target=start_main_thread, daemon=True)
self.__thread.start()

Cleaner().add_multiple(
Expand Down