Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: Stream.pmap, parallele map for streaming data #7

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

dboyliao
Copy link
Contributor

Testing script updated and pass

[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
'''
if processes is None:
processes = os.cpu_count()
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

這應該是 mp.Pool 內建就會做的事。應該維持 None 即可

'''
if processes is None:
processes = os.cpu_count()
pool_chunk_size = max(chunk_size // processes, 1)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

看不懂爲何要除以 processes 數量。系統容許的 queue 大小應該跟 processes 個數無關。

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

我怕 queue 爆掉而已~
所以加了個每個 chunk 會是多少這件事~

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

我改成就傳給 Pool 好了~

if not data:
break
yield from pool.imap(f, data, pool_chunk_size)
return Stream(iter(gen()))
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

要用 @as_stream 包裝比較好。
@as_stream 處理了不少事情,包含 StreamTable 與 Stream 的相容。這樣可以保證 Stream 所有 method 都可以在 StreamTable使用。

另外 iter() 應該是多餘的。

@d2207197
Copy link
Owner

@dboyliao ☝️ 👆

@dboyliao
Copy link
Contributor Author

Orz 我現在才看到~
github 的 notification 我都當沒看到~XDDD

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants