adrn / schwimmbad

A common interface to processing pools.
MIT License
115 stars 18 forks source link

SerialPool not starting #26

Closed AlecThomson closed 4 years ago

AlecThomson commented 5 years ago

Hi there,

I'm currently using version 0.3.0:

In [1]: import schwimmbad
In [2]: schwimmbad.__version__
Out[2]: '0.3.0'

I'm finding that I can't get SerialPool to begin working. Here's a simple script which reproduces the problem:

import schwimmbad

with schwimmbad.MultiPool() as pool:
    inputs = [i for i in range(0,10)]
    pool.map(print, inputs)

with schwimmbad.SerialPool() as pool:
    inputs = [i for i in range(10,20)]
    pool.map(print, inputs)

The only output I get is 0..10. I've found the same problem on more complex examples, with my own functions, and with and without with statements.

Cheers

dfm commented 5 years ago

Does the program hang or exit after that display? What happens if you put a list call around both of the pool.map lines? Thanks!

AlecThomson commented 5 years ago

It doesn't hang, just exits like you would expect.

The list call worked! Is that the expected behaviour, or more of a workaround?

dfm commented 5 years ago

Great! That's the behavior I would expect (map should return an iterator) so I'm surprised that the MultiPool isn't the same!