-
Notifications
You must be signed in to change notification settings - Fork 29
use spawn context #144
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
use spawn context #144
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Summary of Changes
Hello @akaitsuki-ii, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!
此拉取请求旨在解决 multiprocessing 模块中因重复设置启动方法而导致的 RuntimeError。通过使用 spawn 上下文来创建队列,确保了多进程环境的稳定性和兼容性,避免了在上下文已初始化后再次调用 mp.set_start_method("spawn") 引起的错误。
Highlights
- 多进程上下文处理: 移除了显式调用 mp.set_start_method("spawn") 的逻辑,以避免在 multiprocessing 上下文已初始化后重复设置导致的 RuntimeError。
- 队列创建方式优化: 将 mp.Queue() 的创建方式修改为通过 mp.get_context("spawn") 获取的 spawn 上下文来创建队列,确保队列与 spawn 启动方法兼容且一致。
Using Gemini Code Assist
The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.
Invoking Gemini
You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.
| Feature | Command | Description |
|---|---|---|
| Code Review | /gemini review |
Performs a code review for the current pull request in its current state. |
| Pull Request Summary | /gemini summary |
Provides a summary of the current pull request in its current state. |
| Comment | @gemini-code-assist | Responds in comments when explicitly tagged, both in issue comments and review comments. |
| Help | /gemini help |
Displays a list of available commands. |
Customization
To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.
Limitations & Feedback
Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.
You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.
Footnotes
-
Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
这个 Pull Request 旨在解决 multiprocessing 上下文初始化问题。通过改用 mp.get_context("spawn") 来创建 Queue,避免了全局设置 start_method 可能引发的 RuntimeError,因为 start_method 只能设置一次。这是一个很好的改进,使代码更加健壮。我发现了一个小的拼写错误,并已在评论中提出建议。
diffsynth_engine/utils/parallel.py
Outdated
| spwan_ctx = mp.get_context("spawn") | ||
| self.queue_in = spwan_ctx.Queue() | ||
| self.queue_out = spwan_ctx.Queue() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
9fb8f42 to
5a4338b
Compare
可能存在不确定的调用触发了multiprocessing的context的初始化,这个context只能被设置一次,导致后面调用mp.set_start_method("spawn")报错。
替代方法是调用mp.get_context("spawn")返回的context来创建Process和Queue,其中mp.spawn方法内部包含了这个调用,只需要修改创建Queue的逻辑即可。