PickwickSoft / pystreamapi

The Python Stream API Library offering Streams like you know from Java/Kotlin/Scala in Python with some cool extensions
https://pystreamapi.pickwicksoft.org/
GNU General Public License v3.0
30 stars 5 forks source link

Parallel bug - the behavior of parallel() and Stream.parallel_of() not same. #89

Closed NuclearMissile closed 8 months ago

NuclearMissile commented 8 months ago

The behavior of parallel() and Stream.parallel_of() not same.

Calling some actions on parallel stream created by parallel() like filter causes an AttributeError, but Stream.parallel_of() is OK. May because forget to set _parallelizer in StreamConverter.to_parallel_stream().

Error before fix after running test_parallel_stream.py:

Error Traceback (most recent call last): File "/Users//Desktop/projects/pystreamapi/tests/_parallel/test_parallel_stream.py", line 24, in test_parallel .for_each(print)) ^^^^^^^^^^^^^^^ File "/Users//Desktop/projects/pystreamapi/pystreamapi/_streams/base_stream.py", line 36, in wrapper return func(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^ File "/Users//Desktop/projects/pystreamapi/pystreamapi/_streams/base_stream.py", line 50, in wrapper self._queue.execute_all() File "/Users//Desktop/projects/pystreamapi/pystreamapi/_lazy/queue.py", line 22, in execute_all proc.exec() File "/Users//Desktop/projects/pystreamapi/pystreamapi/_lazy/process.py", line 20, in exec self.work(self.arg) File "/Users//Desktop/projects/pystreamapi/pystreamapi/_streams/parallel_stream.py", line 29, in _filter self._set_parallelizer_src() File "/Users//Desktop/projects/pystreamapi/pystreamapi/_streams/parallel_stream.py", line 90, in _set_parallelizer_src self._parallelizer.set_source(self._source, self) ^^^^^^^^^^^^^^^^^^ AttributeError: 'ParallelNumericStream' object has no attribute '_parallelizer'

garlontas commented 8 months ago

Thank you @NuclearMissile for contributing to pystreamapi!