| def run(self): | | def run(self): |
| if self.firsttime: | | if self.firsttime: |
| self.listen() | | self.listen() |
| #... | | #... |
| self.resched(1.0) | | self.resched(1.0) |
| t | | t |
|
| | | ## Setting Up Another Agent to Listen
|
| | |
|
| | | An 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?
|
| | |
|
| | | The 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.
|
| | |
|
| | | However, 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.
|
| | | |
| ## Agent Lifecycle | | ## Agent Lifecycle |
| | | |
| An agent can take either of two basic plans toward | | An agent can take either of two basic plans toward |
| s event listening: | | s event listening: |
| | | |