--
You received this message because you are subscribed to the Google Groups "circuits" group.
To unsubscribe from this group and stop receiving emails from it, send an email to circuits-user...@googlegroups.com.
To post to this group, send email to circuit...@googlegroups.com.
Visit this group at http://groups.google.com/group/circuits-users.
For more options, visit https://groups.google.com/d/optout.
> def foo(self):
> self.call(a()) # synchronously fire and wait for a to complete
> self.call(b()) # synchronously fire and wait for b to complete
> self.fire(c()) # fire off asynchronous event c
except that I’d like A and B to run concurrently, not one after the other. (My first use is a simple animation.) I think that where circuits comes in is that there is no guarantee as to which will finish first or how long it will take.
What I was thinking to do if there isn’t already something like this is to fire off A and B, collect notifications of completion in a set, and fire off C once the set is complete (in this case containing both A and B).
It looks like I would need a Process class to implement the activities, and a class named, say, Director to collect notifications and start new Processes.
In more detail: the starting event would fire A and B; each of these, on completion, would fire a termination event, the Director would collect these and fire off C once it has both. Does this sound like the way to do it?
BTW, it’s already working without circuits. I thought this would be a good project for a rewrite using circuits just to learn the framework. As of now, I know next to nothing and just don’t want to go off in the wrong direction and do something totally unidiomatic.
No this is definitely correct. This contrived tutorial is a working example :)
No this is definitely correct. This contrived tutorial is a working example :)Duh. You are going to laugh your ass off. I’ve obviously been staring at this screen too long. I saw that "result = [result]" is indented and immediately saw the whole two-line phrase as the standard list-accumulation loop. Never mind that it’s an if, not a loop, and never mind that that requires different variables on the two sides of the "=".So am I correct in saying that that bit is there just in case there’s only one dog in the pound because result wouldn’t be a list then?
Let me try again: should the line of text right before this code example say Identify_success instead of identify_success?One other thing: how does the Identify event know to signal success after it has been handled twice? Does it poke around in the registration information looking for items that have the correct handler? I ask because it looks like I could use the Event itself as my Director, particularly if I can put my own code in there to record the replies.
On Jul 1, 2015, at 7:17 PM, James Mills <prol...@shortcircuit.net.au> wrote:On Thu, Jul 2, 2015 at 7:44 AM, James B. Wilkinson <the...@twc.com> wrote:> def foo(self):
> self.call(a()) # synchronously fire and wait for a to complete
> self.call(b()) # synchronously fire and wait for b to complete
> self.fire(c()) # fire off asynchronous event c
except that I’d like A and B to run concurrently, not one after the other. (My first use is a simple animation.) I think that where circuits comes in is that there is no guarantee as to which will finish first or how long it will take.This is a common source of misinterpretation. Do you mean A and B run in parallel? (Quite different to concurrent!)
class a(Event):"""a Event"""complete = True
So we have a Worker() component that wraps around multiprocessing.Pool for running tasks in parallel; you can use call/wait to coordinate and synchronize several or more tasks.See https://bitbucket.org/ccaih/ccav/src/846b536691089eabe560448590c17b9499fdb41c/src/ccav/api/map.py?at=default#cl-135 for a live/production example and inspiration :)
Is this up somewhere and small enough to see what's going on from the code?
Does it spawn processes for the A & B tasks?
What is the overall purpose of the application?
I don’t think so. It runs on a single cpu. I don’t see using the word “parallel” when that’s sthe case. On the other hand, since there’s just one thread, “concurrent” doesn’t fit that well, either. How about “simultaneously”? In any case, I was thinking more of the dictionary definition than the technical term when I said “concurrently”. I’ll have to double check with our OS guy, if he’s in town.
class a(Event):"""a Event"""complete = TrueSomewhere in the docs it will tell me the difference between success and complete? Or maybe it’s just that complete can be true when success is false because of an error.
So we have a Worker() component that wraps around multiprocessing.Pool for running tasks in parallel; you can use call/wait to coordinate and synchronize several or more tasks.See https://bitbucket.org/ccaih/ccav/src/846b536691089eabe560448590c17b9499fdb41c/src/ccav/api/map.py?at=default#cl-135 for a live/production example and inspiration :)mañana
Is this up somewhere and small enough to see what's going on from the code?It’s about 250 lines of code, attached herewith. In the neighborhood of line 160 is the move method. It moves the object a couple of pixels and schedules itself to run again after a couple of milliseconds. That’s how the interleaving of A and B is all in one thread.At line 210 ff. is the code that starts it going. The start method takes a parameter that is a function to run when it finishes. It runs A, then B, then resets itself and runs A and B simultaneously. Then it resets to the initial state and stops. That code is in the termination methods that get passed to the start method on the various times that it gets called.
Does it spawn processes for the A & B tasks?No it’s all in one process.
What is the overall purpose of the application?It’s a classroom demo for my class in computer organization. The full program (which I didn’t send yet) shows a model of a simplified MIPS cpu. Numbers from the register file travel to the alu and get combined (add, sub, ...) into a single number that then travels back around and gets written into a register. What I sent you is just the traveling part with a silly proof-of-concept demo tacked onto the end as main(). The advantage is that all you need is that one file, python3 and tkinter. And you don’t have to look at all the crazy code that hooks the reusable pieces together visually. I thought about learning enough Alice to do it, but our Alice chick said to do it in python.
One other thing: how does the Identify event know to signal success after it has been handled twice? How does it know not to wait on some more dogs to bark?I ask because it looks like I could use the Event itself as my Director, particularly if I can put my own code in there to record the replies.