update global variable to reflect it pool function

-2

I am trying to update my variable dsp with fresh value each time while cycle runs. But this code is not working. Any idea please?

Edit: My goal is to update variable dst in while cycle and then share it with all processes (so processes ideally do not need to call display.Display() inside each process to save CPU time)

from PIL import Image
from Xlib import display, X
from multiprocessing import Pool

def doWork(N):
    global dsp # --- here I want to use global dst variable from while cycle      
    root = dsp.screen().root
    raw = root.get_image(0,0,200,200, X.ZPixmap, 0xffffffff)
    im = Image.frombytes("RGB", (200,200), raw.data, "raw", "BGRX")
    #return im

    return im  


if __name__ == "__main__":
    pool = Pool(processes=3)

    while True:
        global dsp
        dsp = display.Display()

        results = pool.map(doWork, (1, 2) )
        print results
python
python-2.7
asked on Stack Overflow Jul 19, 2018 by peter • edited Jul 21, 2018 by peter

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0