Skip to content

How to shared memory between main process and plugin ? #1415

Answered by LoickZoty
LoickZoty asked this question in Q&A
Discussion options

You must be logged in to vote

Initially, I opted for this solution: https://docs.python.org/3/library/multiprocessing.shared_memory.html.
This allowed me to share my variables directly from the buffer.

However, I became interested in your solution, which gave me the following result.

app.py

def start_proxy(self, p: ProxyModel):
    p.started = True
    with proxy.Proxy(input_args=self.create_input_args(p)) as p_process:
        while proxy_service.proxies[p.id] and proxy_service.proxies[p.id].started:
            self.update_proxy(p, p_process.event_manager.queue.queue)
            self.stop_proxy(p)

def update_proxy(self, p: ProxyModel, queue: Queue):
    try:
        update = queue.get(timeout=1)
        if update["…

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
2 replies
@abhinavsingh
Comment options

@abhinavsingh
Comment options

Answer selected by abhinavsingh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants