Intrathread/process pubsub?

19 views
Skip to first unread message

DJW

unread,
Jan 8, 2012, 12:28:10 AM1/8/12
to cherrypy-users
I've been reading up on CherryPy's wspbus but couldn't find a concrete
answer for a problem I'm trying to solve.

Rough outline is that I am writing a on-demand javascript coverage
utility. I overrode the stock staticdir tool to accomplish this, but
now I wanted to implement a simple filter to decide where to serve the
real JS resource or an instrumented version.

The crux of it is that in my version of staticdir I would need to send
a query over the bus to a central control subscriber which would
return True/False Process/Pass-thru. Is something like this possible
with wspbus or should I look to use an external message queue service.

Anders Langworthy

unread,
Jan 8, 2012, 12:21:22 PM1/8/12
to cherryp...@googlegroups.com

This should be possible with wspbus. You'd write your central
subscriber as a plugin. See for example the way the template tool &
plugin interact in Sylvain's app here:
https://bitbucket.org/Lawouach/twiseless/src

DJW

unread,
Jan 9, 2012, 5:18:05 AM1/9/12
to cherrypy-users
Looks like it is possible:

Subscriber side calls on the bus to get a new mako.Template instance
https://bitbucket.org/Lawouach/twiseless/src/d171fde9e454/lib/tool/template.py#cl-22

And service responds here:
https://bitbucket.org/Lawouach/twiseless/src/d171fde9e454/lib/plugin/template.py#cl-40

Very nice and much appreciation for pointing this repository out.

Sylvain Hellegouarch

unread,
Jan 9, 2012, 5:51:57 AM1/9/12
to cherryp...@googlegroups.com
On Mon, Jan 9, 2012 at 11:18 AM, DJW <ward....@gmail.com> wrote:
Looks like it is possible:

Subscriber side calls on the bus to get a new mako.Template instance
https://bitbucket.org/Lawouach/twiseless/src/d171fde9e454/lib/tool/template.py#cl-22

And service responds here:
https://bitbucket.org/Lawouach/twiseless/src/d171fde9e454/lib/plugin/template.py#cl-40

Very nice and much appreciation for pointing this repository out.




Yes that's about it really. Note though that the bus implementation in CP is straightforward and runs within the current process's loop. In other words, the longer your plugins take to perform their tasks, the worse your performance may become. It could be interesting to have the bus implemented atop zeromq or something similar someday. 

--
- Sylvain
http://www.defuze.org
http://twitter.com/lawouach
Reply all
Reply to author
Forward
0 new messages