[New-bugs-announce] [issue39257] contextvars.Context.run hangs forever in ProccessPoolExecutor

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

New submission from Ron Serruya <ron.serruya at gmail.com>:

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' # ***** This hangs forever *****
    ctx = copy_context()
    p = Process(target=ctx.run, args=(list,))

python version is 3.8.0
running on Mac OSX 10.15.1

messages: 359575
nosy: ronserruya
priority: normal
severity: normal
status: open
title: contextvars.Context.run hangs forever in ProccessPoolExecutor
type: behavior
versions: Python 3.8

Python tracker <report at bugs.python.org>

More information about the New-bugs-announce mailing list