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

请问支持局域网内多pc端同时调用该web服务吗,如果支持pc端同时调用的话各自数据会冲突吗 #60

Open
HaoRenkk123 opened this issue Oct 30, 2024 · 3 comments

Comments

@HaoRenkk123
Copy link

不是很懂gradio也不太懂web端,想知道这个项目如果启动后,是否满足多人同时在各自pc上同时调用

@MrGreyfun
Copy link
Owner

MrGreyfun commented Oct 30, 2024

你好,可以多人同时调用,专门做过这个适配,每次访问这个链接产生的数据和代码运行环境都是相互隔离的

@HaoRenkk123
Copy link
Author

好的谢谢,想请教下,这个相互隔离的代码部分在什么地方呢,或者这个隔离是gradio 服务自身支持的呢?

@MrGreyfun
Copy link
Owner

互相隔离的代码主要是通过web_ui.py中的这个函数:

def initialization(state_dict: Dict) -> None:
    if not os.path.exists('cache'):
        os.mkdir('cache')
    if state_dict["bot_backend"] is None:
        state_dict["bot_backend"] = BotBackend()
        if 'OPENAI_API_KEY' in os.environ:
            del os.environ['OPENAI_API_KEY']

每次访问网址的时候,调研这个函数,它会专门为会话实例化一个BotBackend,其中包含了数据和代码执行环境。state_dict只和当前会话中使用。

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

No branches or pull requests

2 participants