multiprocessing.Manager() sharing common data

Hello all.

I’m using VSCode and Python 3.12.0
My exploring multiprocessing and I can’t get past an issue with passing data between main and subProcess . I have 2 files appMain.py and appUserInterface.py in the same scr folder.

appMain.py

from  multiprocessing import Process, Manager, current_process
import os
import sys
import dataLogger
from datetime import datetime, timedelta
import time
import pytz

logger = dataLogger.setupLogging('appMain')

def subPrograms(subProgram, sharedDataAddr, authKey):
    pythonExecutable = sys.executable
    programPath = os.path.join('..', 'myApp', 'scr', subProgram)
    os.execl(pythonExecutable, pythonExecutable, programPath, sharedDataAddr, authKey)

def activateProcesses(subProgram, sharedDataAddr, authKey):
    process = Process(target=subPrograms, args=(subProgram, sharedDataAddr, authKey))
    process.start()
    process.join()

def main():
    eastern = pytz.timezone('US/Eastern')
    
    manager = Manager()
    sharedData = manager.dict({
        'exitUserInterface': False,
        'exitMain': False,
        'aliveTimeUserInterface': datetime.now(eastern).timestamp(),
        'aliveTimeMain': datetime.now(eastern).timestamp(),
    })

    sharedDataAddr = manager.address
    authKey = manager._authkey.decode('latin1')

    while True:#not vars.exitMain:
        logger.error(f"sharedData =     { sharedData}")
        logger.error(f"sharedDataAddr = { sharedDataAddr}")
        logger.error(f"authKey =        { authKey}")
        activateProcesses('appUserInterface.py', sharedDataAddr, authKey)
        #time.sleep(2)

if __name__ == '__main__':
    logger.debug(f'__name__ = {'appMain started'}')
    main()
    logger.debug(f'__name__ = {'appMain Finished'}')

appUserInterface.py

import dataLogger
from datetime import datetime
import sys
import pytz
import multiprocessing.managers

logger = dataLogger.setupLogging('appUserInterface')

def main(sharedDataAddr, authKey):
    eastern = pytz.timezone('US/Eastern')

    class SharedDataManager(multiprocessing.managers.BaseManager): pass

    SharedDataManager.register('dict')

    manager = SharedDataManager(address=sharedDataAddr, authkey=authKey.encode('latin1'))
    manager.connect()
    sharedData = manager.dict()
    logger.error(f"sharedData =     { sharedData}")
    logger.error(f"sharedDataAddr = { sharedDataAddr}")
    logger.error(f"authKey =        { authKey}")

    sharedData['aliveTimeUserInterface'] = datetime.now(eastern).timestamp()
    sharedData['exitUserInterface'] = True

if __name__ == '__main__':
    if len(sys.argv) != 3:
        logger.error("Usage: appUserInterface.py sharedDataAddr authKey")
        sys.exit(1)
    main(sys.argv[1], sys.argv[2])

my logger output

20240710-10:38:24 - appMain - ERROR - sharedData =     {'exitUserInterface': False, 'exitMain': False, 'aliveTimeUserInterface': 1720622302.286862, 'aliveTimeMain': 1720622302.286862}
20240710-10:38:24 - appMain - ERROR - sharedDataAddr = \\.\pipe\pyc-9364-0-quwdygfx
20240710-10:38:24 - appMain - ERROR - authKey =        e9PÊ¿T�X‰6Kóí¾è0£ÒO¼£WšG
20240710-10:38:24 - appUserInterface - ERROR - sharedData =     {}
20240710-10:38:24 - appUserInterface - ERROR - sharedDataAddr = \\.\pipe\pyc-9364-0-quwdygfx
20240710-10:38:24 - appUserInterface - ERROR - authKey =        e9PÊ¿T�X‰6Kóí¾è0£ÒO¼£WšG

I’d appreciate any help with resolving this issue

Go figure. I couldn’t get this to work so I posted the question. Soon after I found the answer or what looks like the answer.
I added

serializedSharedData = base64.b64encode(pickle.dumps(dict(sharedData))).decode('utf-8')

to

def activateProcesses(subProgram, sharedDataAddr, authKey, sharedData):
    serializedSharedData = base64.b64encode(pickle.dumps(dict(sharedData))).decode('utf-8')
    process = Process(target=subPrograms, args=(subProgram, sharedDataAddr, authKey, serializedSharedData))      # Create a new process
    process.start()                                                                                             # Start the process
    process.join()