[issue39257] contextvars.Context.run hangs forever in ProccessPoolExecutor

Ron Serruya report at bugs.python.org
Wed Jan 8 05:37:29 EST 2020


Ron Serruya <ron.serruya at gmail.com> added the comment:

Sending Context.run to another process via ProccessPoolExecutor hangs forever:

```
from contextvars import ContextVar, copy_context
from concurrent.futures import ProcessPoolExecutor
from multiprocessing import Process

var: ContextVar[int] = ContextVar('var',default=None)

if __name__ == '__main__':
    
    # ***** This hangs forever *****
    with ProcessPoolExecutor(max_workers=1) as pp:
        ctx = copy_context()
        pp.submit(ctx.run, list)

    # ****** This throws 'cannot pickle Context' ***** 
    ctx = copy_context()
    p = Process(target=ctx.run, args=(list,))
    p.start()
    p.join()
```

python version is 3.8.0
running on Mac OSX 10.15.1

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue39257>
_______________________________________


More information about the Python-bugs-list mailing list