A beginner's guide about cherrypy.server and cherrypy.engine

54 views
Skip to first unread message

niuji...@gmail.com

unread,
Jan 2, 2022, 2:37:23 AMJan 2
to cherrypy-users
I've read through documentations along with some books like 'CherryPy Essentials', but found confused about some fundamental concepts. What is the relationship between `cherrypy.server` and `cherrypy.engine`? Why separate those two parts into different modules?

Can someone recommend some readings that explain this in a beginner-friendly way? Thanks.

Sylvain Hellegouarch

unread,
Feb 28, 2022, 5:38:36 AMFeb 28
to cherryp...@googlegroups.com
Hello,

Long late overdue response. But I hope this will help a bit.

cherrypy.engine is basically like the core loop of CherryPy.
The goal of the engine is to provide a solid management of the process and all the components running as part of it.

It is designed around a simple pub/sub approach.
When an instance of the engine starts, it sends messages to various channels you can subscribe to.
Anything that wants to run as part of the engine lifecycle must abide by this interface of channels and messages.

The cherrypy.server is obviously the main component that you want to run in a CherryPy application.
But the server still has to hook itself to these messages to be executed and part of the lifecycle of the engine.

You can see this happening here:

That subscribe() call ensures the server will be running as part of the engine (the main loop if you will).

So engine and server have different purposes but the server makes use of the engine lifecycle to be a good citizen during the process's life.

I hope this helps a bit?

By the way, I'm the author of the book, I appreciate you reading it. It's 15 years old, I wouldn't count it as a good resource any longer :p
I wrote a lot of the documentation too years ago but it may still be lacking. Sorry for that :(

- Sylvain


Le dim. 2 janv. 2022 à 08:37, niuji...@gmail.com <niuji...@gmail.com> a écrit :
I've read through documentations along with some books like 'CherryPy Essentials', but found confused about some fundamental concepts. What is the relationship between `cherrypy.server` and `cherrypy.engine`? Why separate those two parts into different modules?

Can someone recommend some readings that explain this in a beginner-friendly way? Thanks.

--
You received this message because you are subscribed to the Google Groups "cherrypy-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cherrypy-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/cherrypy-users/3ce9333c-98ce-43e6-bb3f-d8455031f894n%40googlegroups.com.


--
- Sylvain Hellegouarch

Jinghui Niu

unread,
Apr 30, 2022, 2:34:05 AMApr 30
to cherryp...@googlegroups.com
Hi Sylvain,
Thank you for your reply. I feel very honored to have the author of that book reply in such a detailed manner. And it is a very clear one. Definitely helps.

I was wondering why there are so few books or courses on CherryPy? Maybe you should consider writing a 'missing manual' kind of book? I'll definitely be your reader:)

You received this message because you are subscribed to a topic in the Google Groups "cherrypy-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/cherrypy-users/hi5iwV3_79I/unsubscribe.
To unsubscribe from this group and all its topics, send an email to cherrypy-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/cherrypy-users/CALkdAkiqvq8fFmuNOuDqwT70_ay82Zof7YF%2BbCvMLDiBEBy14w%40mail.gmail.com.
Reply all
Reply to author
Forward
0 new messages