fix creation of queue on dummy
This commit is contained in:
@ -1,9 +1,9 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
""" Author: Hendrik Schutter, localhorst@mosad.xyz
|
||||
Date of creation: 2022/11/23
|
||||
Date of last modification: 2025/06/15
|
||||
"""Author: Hendrik Schutter, localhorst@mosad.xyz
|
||||
Date of creation: 2022/11/23
|
||||
Date of last modification: 2025/06/15
|
||||
"""
|
||||
|
||||
import ctypes
|
||||
@ -119,6 +119,7 @@ def create_drive_objects(drive_info):
|
||||
def worker(queue_id, test_mode=False):
|
||||
try:
|
||||
while not terminate:
|
||||
time.sleep(3)
|
||||
if test_mode:
|
||||
drive_info = {
|
||||
"driveIndex": "42",
|
||||
@ -167,7 +168,6 @@ def worker(queue_id, test_mode=False):
|
||||
"driveSerialnumber": d.caDriveSerialnumber.decode().strip("\x00"),
|
||||
"driveReHddVersion": d.caDriveReHddVersion.decode().strip("\x00"),
|
||||
}
|
||||
time.sleep(3)
|
||||
|
||||
print(f"Received Drive Data: {drive_info}")
|
||||
|
||||
@ -204,9 +204,16 @@ def main():
|
||||
return
|
||||
while True:
|
||||
try:
|
||||
queue_id = msgget(MSG_QUEUE_KEY, 0)
|
||||
# Create or connect to the message queue with IPC_CREAT flag
|
||||
# This matches the C++ sender's flags (IPC_CREAT | 0666)
|
||||
queue_id = msgget(MSG_QUEUE_KEY, IPC_CREAT | 0o666)
|
||||
if queue_id == -1:
|
||||
raise RuntimeError("Failed to connect to the existing message queue.")
|
||||
err = ctypes.get_errno()
|
||||
raise RuntimeError(
|
||||
f"Failed to create/connect to the message queue: {os.strerror(err)}"
|
||||
)
|
||||
|
||||
print(f"Successfully connected to message queue (ID: {queue_id})")
|
||||
worker(queue_id)
|
||||
except Exception as e:
|
||||
print(f"Main process encountered an error: {e}")
|
||||
|
||||
Reference in New Issue
Block a user