CherryPy用于虚拟主机控制面板应用程序

时间:2021-02-08 00:06:31

For quite a long time I've wanted to start a pet project that will aim in time to become a web hosting control panel, but mainly focused on Python hosting -- meaning I would like to make a way for users to generate/start Django/ other frameworks projects right from the panel. I seemed to have found the perfect tool to build my app with it: CherryPy.

很长一段时间我都想开始一个宠物项目,该项目将及时成为一个Web托管控制面板,但主要关注Python托管 - 这意味着我想为用户创建/启动Django /小组中的其他框架项目。我似乎找到了用它构建我的应用程序的完美工具:CherryPy。

This would allow me to do it the way I want, building the app with its own HTTP/ HTTPS server and also all in my favorite programming language.

这将允许我按照我想要的方式进行,使用自己的HTTP / HTTPS服务器构建应用程序,并使用我最喜欢的编程语言。

But now a new question arises: As CherryPy is a threaded server, will it be the right for this kind of task?

但是现在出现了一个新问题:由于CherryPy是一个线程服务器,它是否适合这种任务?

There will be lots of time consuming tasks so if one of the tasks blocks, the rest of the users trying to access other pages will be left waiting and eventually get timed out.

将会有许多耗时的任务,因此如果其中一个任务阻塞,其他试图访问其他页面的用户将等待并最终超时。

I imagine that this kind of problem wouldn't happen on a fork based server.

我想这种问题不会发生在基于fork的服务器上。

What would you advise?

你有什么建议吗?

1 个解决方案

#1


1  

"Threaded" and "Fork based" servers are equivalent. A "threaded" server has multiple threads of execution, and if one blocks then the others will continue. A "Fork based" server has multiple processes executing, and if one blocks then the others will continue. The only difference is that threaded servers by default will share memory between the threads, "fork based" ones by default will not share memory.

“螺纹”和“基于叉”的服务器是等效的。 “线程”服务器具有多个执行线程,如果一个阻塞,则其他线程将继续。 “基于Fork”的服务器有多个进程在执行,如果有一个阻塞,则其他进程将继续执行。唯一的区别是默认情况下线程服务器将在线程之间共享内存,默认情况下“基于fork”的服务器不会共享内存。

One other point - the "subprocess" module is not thread safe, so if you try to use it from CherryPy you will get wierd errors. (This is Python Bug 1731717)

另一点 - “子进程”模块不是线程安全的,所以如果你尝试在CherryPy中使用它,你将会遇到奇怪的错误。 (这是Python Bug 1731717)

#1


1  

"Threaded" and "Fork based" servers are equivalent. A "threaded" server has multiple threads of execution, and if one blocks then the others will continue. A "Fork based" server has multiple processes executing, and if one blocks then the others will continue. The only difference is that threaded servers by default will share memory between the threads, "fork based" ones by default will not share memory.

“螺纹”和“基于叉”的服务器是等效的。 “线程”服务器具有多个执行线程,如果一个阻塞,则其他线程将继续。 “基于Fork”的服务器有多个进程在执行,如果有一个阻塞,则其他进程将继续执行。唯一的区别是默认情况下线程服务器将在线程之间共享内存,默认情况下“基于fork”的服务器不会共享内存。

One other point - the "subprocess" module is not thread safe, so if you try to use it from CherryPy you will get wierd errors. (This is Python Bug 1731717)

另一点 - “子进程”模块不是线程安全的,所以如果你尝试在CherryPy中使用它,你将会遇到奇怪的错误。 (这是Python Bug 1731717)