Defines operations that will be executed once at task startup. Useful when implementing processors, that don't have access to the Task top-level structure. This setup will be run only once, even if multiple instances of the task will run in parallel. For ins
(self)
| 365 | return _RunWhileCondition(name=name) |
| 366 | |
| 367 | def task_init(self): |
| 368 | """ |
| 369 | Defines operations that will be executed once at task startup. |
| 370 | Useful when implementing processors, that don't have access to the Task |
| 371 | top-level structure. |
| 372 | |
| 373 | This setup will be run only once, even if multiple instances of the task |
| 374 | will run in parallel. For instance-local initialization, use |
| 375 | `task_instance_init` instead. |
| 376 | |
| 377 | Example: |
| 378 | def my_processor(rec): |
| 379 | with ops.task_init(): |
| 380 | one = ops.Const(1) |
| 381 | two = ops.Const(1) |
| 382 | return Tuple( |
| 383 | ops.Add(rec[0](), zero), ops.Add(rec[1](), two)) |
| 384 | """ |
| 385 | setup = _SetupBuilder(_SetupBuilder.INIT) |
| 386 | self.net().add_attribute(Task.TASK_SETUP, setup) |
| 387 | return setup |
| 388 | |
| 389 | def task_exit(self): |
| 390 | """ |