auto_reload callback

46 views
Skip to first unread message

yota...@gmail.com

unread,
Jan 11, 2023, 2:58:07 PM1/11/23
to cherrypy-users
Hello,

I love the autoreload functionnality, especially while developing apps. But here, for the first time, I stumbled over a new problem.

I usually launch my server like this
cherrypy.tree.mount(dummy_class_instance, '/', config=custom_config_dict)

cherrypy.engine.start()
cherrypy.engine.block()

But today, I also play with gstreamer (this webapp command a music player) which requires a call to
gloop = GLib.MainLoop()
gloop.run()

Which I place just after the cherrypy engine start() and before the block(). It works perfectly fine until the auto reload kicks in and... get stuck mid way by the GLib.MainLoop. Is it possible to attach something to this auto_reload procedure to trigger a MainLoop.quit() somehow ?

Another alternative would be to put this GLib stuff in a completely separate process but I would like to avoid this if possible.

Thanks :)

Sviatoslav Sydorenko (@webknjaz)

unread,
Jan 16, 2023, 11:54:03 AM1/16/23
to cherrypy-users
Hi,

середа, 11 січня 2023 р. о 20:58:07 UTC+1 yota...@gmail.com пише:
Which I place just after the cherrypy engine start() and before the block(). It
works perfectly fine until the auto reload kicks in and... get stuck mid way by

the GLib.MainLoop. Is it possible to attach something to this auto_reload
procedure to trigger a MainLoop.quit() somehow ?

I believe you're looking for the plugins interface[1]. You can implement one by
putting the corresponding snippets into the `start()` and `stop()` methods of
your plugin and storing a reference to `gloop` as an instance attribute.  Once
registered with the pub-sub bus (`cherrypy.engine`), it'll take care of calling
said methods when appropriate.

yota...@gmail.com

unread,
Jan 17, 2023, 4:05:58 PM1/17/23
to cherrypy-users

Thank you for the link ! I will read the doc I try to implement a plugin to my tastes :)

Yota
Reply all
Reply to author
Forward
0 new messages