Twisted for non-networking applications

James Mills prologic at shortcircuit.net.au
Mon Dec 22 06:46:29 CET 2008


On Mon, Dec 22, 2008 at 3:25 PM, RajNewbie <raj.indian.08 at gmail.com> wrote:
> I was unable to see documentation explaining this - so asking again.

Documentation is available here:
http://trac.softcircuit.com.au/circuits/wiki/docs
And here: pydoc circuits

The code itself is heavily documented. I'm still
writing better online references, tutorials
and what not ... :) Please see the examples/

> Suppose the event handlers in the component is doing blocking work,
> how is it handled?

You have a few options.
1. Do your work in a thread.
2. Do your work in a process.

You could utilize the Worker component for
such things. I'm also building a Process
component that uses the multiprocessing module.

> I went through ciruits.core, but was unable to understand exactly how
> blocking mechanisms are handled.

They aren't. It's up to you to handle such
situations. If your "event-handler" blocks,
everything, it will block every other event
handler from being processes.

In what situation would you have this ?
I'm curious :)

> My scenario is as follows:
> I have 4 loops, 1 small and high priority, 3 quite large and blocking
> (takes upto 3 seconds) and comparatively low priority.
> The small loops goes through everytime and does some work - and
> optionally uses the data sent by the other 3 loops.
> I do not want the smaller loop to get blocked by the other loops.

This sounds complex :) What is your application ?
What's being processes ?

> So, if the event handler does blocking work, can that cause the whole
> loop to block?

Yes. If you decide to use circuits, I suggest
you restructure your program. Try to do
your work (if it's blocking) in Worker components (threads).

cheers
James



More information about the Python-list mailing list