Event

<= Previous Change

Diff Summary
Title
Date 2007-10-16 16:23 2007-10-16 16:48
Editor Andrew Plotkin (zarf) Andrew Plotkin (zarf)

2007-10-16 16:23 by Andrew Plotkin
2007-10-16 16:48 by Andrew Plotkin
19    def run(self):19    def run(self):
20      if self.firsttime:20      if self.firsttime:
21        self.listen()21        self.listen()
22      #...22      #...
23      self.resched(1.0)23      self.resched(1.0)
tt24
25## Setting Up Another Agent to Listen
26
27An agent's listen() method should only be called b
 >y the agent itself. What if you want to create ano
 >ther agent, and set *it* listening?
28
29The obvious path is to put the listen() call in it
 >s run() method, as described above. The first time
 > the new agent runs, it will begin listening.
30
31However, if you find this scheme (or the `firsttim
 >e` field) to be inelegant, you can create the agen
 >t and call its post_agent() method. This sets it u
 >p (without scheduling it), and then calls listen()
 > for you.
2432
25## Agent Lifecycle33## Agent Lifecycle
2634
27An agent can take either of two basic plans toward35An agent can take either of two basic plans toward
>s event listening:>s event listening:
2836
Event - last changed 2007-10-16 16:48 by Andrew Plotkin (zarf)