from panda3d.core import PythonTask

class PythonTask

Bases: AsyncTask

This class exists to allow association of a Python function or coroutine with the AsyncTaskManager.

Inheritance diagram

__init__(function: object, name: str) → None
__init__(param0: PythonTask) → None
operatorNew(size: size_t) → None
setFunction(function: object) → None
getFunction() → object

Returns the function that is called when the task runs.

setArgs(args: object, append_task: bool) → None
getArgs() → object
setUponDeath(upon_death: object) → None
getUponDeath() → object

Returns the function that is called when the task finishes.

setOwner(owner: object) → None
getOwner() → object

Returns the “owner” object. See setOwner().

setResult(result: object) → None

Sets the “result” of this task. This is the value returned from an “await” expression on this task. This can only be called while the task is still alive.

static getClassType() → TypeHandle
Return type

TypeHandle

property time

The amount of seconds that have elapsed since the task was started, according to the task manager’s clock.

Returns the amount of time that has elapsed since the task was started, according to the task manager’s clock.

It is only valid to call this if the task’s status is not S_inactive.

Return type

float

property wake_time

If this task has been added to an AsyncTaskManager with a delay in effect, this contains the time at which the task is expected to awaken. It has no meaning of the task has not yet been added to a queue, or if there was no delay in effect at the time the task was added. If the task’s status is not S_sleeping, this contains 0.0.

If this task has been added to an AsyncTaskManager with a delay in effect, this returns the time at which the task is expected to awaken. It has no meaning if the task has not yet been added to a queue, or if there was no delay in effect at the time the task was added.

If the task’s status is not S_sleeping, this returns 0.0.

If this task has been added to an AsyncTaskManager with a delay in effect, this returns the time at which the task is expected to awaken. It has no meaning if the task has not yet been added to a queue, or if there was no delay in effect at the time the task was added.

If the task’s status is not S_sleeping, this returns 0.0.

Return type

float

property wakeTime

Alias of wake_time.

If this task has been added to an AsyncTaskManager with a delay in effect, this returns the time at which the task is expected to awaken. It has no meaning if the task has not yet been added to a queue, or if there was no delay in effect at the time the task was added.

If the task’s status is not S_sleeping, this returns 0.0.

If this task has been added to an AsyncTaskManager with a delay in effect, this returns the time at which the task is expected to awaken. It has no meaning if the task has not yet been added to a queue, or if there was no delay in effect at the time the task was added.

If the task’s status is not S_sleeping, this returns 0.0.

Return type

float

property delay_time

The delay value that has been set on this task, if any, or None.

Getter

Returns the delay value that has been set via set_delay, if any.

Returns the delay value that has been set via set_delay, if any.

Setter

Specifies the amount of time, in seconds, by which this task will be delayed after it has been added to the AsyncTaskManager. At least the specified amount of time (and possibly more) will elapse before the task begins.

You may specify a delay of 0.0 to guarantee that the task will run in the next epoch following the one in which it is added.

Setting this value after the task has already been added will not affect the task’s wake time; it will only affect the task if it is re-added to the queue in the future, for instance if the task returns DS_again. However, see recalc_wake_time() if you wish to apply the delay effect immediately.

Specifies the amount of time, in seconds, by which this task will be delayed after it has been added to the AsyncTaskManager. At least the specified amount of time (and possibly more) will elapse before the task begins.

You may specify a delay of 0.0 to guarantee that the task will run in the next epoch following the one in which it is added.

Setting this value after the task has already been added will not affect the task’s wake time; it will only affect the task if it is re-added to the queue in the future, for instance if the task returns DS_again. However, see recalc_wake_time() if you wish to apply the delay effect immediately.

Return type

float

property delayTime

Alias of delay_time.

Getter

Returns the delay value that has been set via set_delay, if any.

Returns the delay value that has been set via set_delay, if any.

Setter

Specifies the amount of time, in seconds, by which this task will be delayed after it has been added to the AsyncTaskManager. At least the specified amount of time (and possibly more) will elapse before the task begins.

You may specify a delay of 0.0 to guarantee that the task will run in the next epoch following the one in which it is added.

Setting this value after the task has already been added will not affect the task’s wake time; it will only affect the task if it is re-added to the queue in the future, for instance if the task returns DS_again. However, see recalc_wake_time() if you wish to apply the delay effect immediately.

Specifies the amount of time, in seconds, by which this task will be delayed after it has been added to the AsyncTaskManager. At least the specified amount of time (and possibly more) will elapse before the task begins.

You may specify a delay of 0.0 to guarantee that the task will run in the next epoch following the one in which it is added.

Setting this value after the task has already been added will not affect the task’s wake time; it will only affect the task if it is re-added to the queue in the future, for instance if the task returns DS_again. However, see recalc_wake_time() if you wish to apply the delay effect immediately.

Return type

float

property frame

The number of frames that have elapsed since the task was started, according to the task manager’s clock.

Returns the number of frames that have elapsed since the task was started, according to the task manager’s clock.

It is only valid to call this if the task’s status is not S_inactive.

Return type

int