Accessing shared context from custom process?

Hi everyone, i am trying to access a shared context queue from a custom process:

app = Sanic("Server")

def subprocess():
       while True:
            msg = app.shared_ctx.vjQueue.get()

async def launchProcesses(app):
    app.manager.manage("subprocess", subprocess)

async def createDicts(app):
    app.shared_ctx.vjQueue= Queue()

however, this results in AttributeError: 'SharedContext' object has no attribute 'vjQueue'. Does the subprocess not have access to the shared context or what am i doing wrong?

Sorry for the late reply.

Of course you can! You just need to be explicit about it and actually pass the context object as an argument.

from multiprocessing import Queue
from queue import Empty
from time import sleep

from sanic import Request, Sanic, json

def my_process(q):
    print("Entering process")
        while True:
                print("Received:", q.get(timeout=1))
            except Empty:
    except KeyboardInterrupt:

app = Sanic("TestApp")

async def handler(request: Request):
    return json({"foo": "bar"})

async def main_process_start(app):
    app.shared_ctx.queue = Queue()

async def ready(app: Sanic, _):
    app.manager.manage("MyProcess", my_process, {"q": app.shared_ctx.queue})