noxdafox / pebble

Multi threading and processing eye-candy.
GNU Lesser General Public License v3.0
525 stars 49 forks source link

ISSUE with with ProcessPool when scheduled function return exception (not raise it) #123

Closed sergeykk closed 9 months ago

sergeykk commented 10 months ago

in the following snippet there are no difference in handling for worker1 and worker2. f[1|2].result() raises exception, while it's expected that only invocation of worker2 will raise exception, but value of r1 will be ValueError(). concurrent.futures.ProcessPoolExecutor() handles this correctly.

import pebble

def worker1():
    return ValueError(1)

def worker2():
    raise ValueError(1)

def test_process_pool():
    max_workers = 2
    executor = pebble.ProcessPool(max_workers=max_workers)
    f1 = executor.submit(worker1, timeout=None)
    r1 = f1.result()                             # throw exception instead of returning ValueError(1)
    assert r1 == ValueError(1) 
    executor.join()
noxdafox commented 9 months ago

Issue should be resolved in 5.0.5. Please re-open if the problem persists/