You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Sub-handlers in a 'resume' event should be executed in parallel.
Actual Behavior
I've got one function both for create/update and resume events handling. create/update sub-handlers work in parallel without any issues. The same code for a resume event handler is executed one-by-one.
Hm. That is interesting. e0ne Can you please describe ho do you check that the handlers are executed in parallel?
The handlers for one single object are never executed in parallel, they are always sequential by design. More on that, it is not possible that the creation & update events happen at the same time (for update to happen, the object must be created already).
Multiple different objects are handled in parallel though (each with its own sequence of handlers).
This is also valid for the sub-handlers: they are executed in sequence (not necessary in the order given, but at most one at a time), and the original top-level handler is waiting for them.
So, it is not clear what do you mean that create/update are executed in parallel.
Also, I see that you call kopf.execute() directly. This will not work at all — the sub-handlers will not be executed. kopf.execute() is a coroutine, not a function, so it must be awaited.
Notice, that for await to be usable, the whole function must be declared as async def, and it is better if it is really async and non-blocking then (regular async/await development practices).
If actual parallel execution (but not handling) is needed, it is better to use the Python's parallelisation with threads or asyncio tasks.
I assume, the issue is fixed. The "parallel execution" issue is explained above — it never existed, and, perhaps, is just a terminology misunderstanding.
If the issue with the on-resume handlers continues to reappear in >=0.23rc1, feel free to re-open this issue with a describing comment (or at least just leave a comment).
The text was updated successfully, but these errors were encountered:
Expected Behavior
Sub-handlers in a 'resume' event should be executed in parallel.
Actual Behavior
I've got one function both for create/update and resume events handling. create/update sub-handlers work in parallel without any issues. The same code for a resume event handler is executed one-by-one.
Steps to Reproduce the Problem
Specifications
Hm. That is interesting. e0ne Can you please describe ho do you check that the handlers are executed in parallel?
The handlers for one single object are never executed in parallel, they are always sequential by design. More on that, it is not possible that the creation & update events happen at the same time (for update to happen, the object must be created already).
Multiple different objects are handled in parallel though (each with its own sequence of handlers).
This is also valid for the sub-handlers: they are executed in sequence (not necessary in the order given, but at most one at a time), and the original top-level handler is waiting for them.
So, it is not clear what do you mean that create/update are executed in parallel.
Also, I see that you call
kopf.execute()
directly. This will not work at all — the sub-handlers will not be executed.kopf.execute()
is a coroutine, not a function, so it must be awaited.I assume, you have taken it from the docs at https://kopf.readthedocs.io/en/latest/handlers/, don't you? It seems, the example there is wrong. Another page is more correct on
await kopf.execute(...)
: https://kopf.readthedocs.io/en/latest/idempotence/ I will fix it soon.Notice, that for
await
to be usable, the whole function must be declared asasync def
, and it is better if it is really async and non-blocking then (regular async/await development practices).If actual parallel execution (but not handling) is needed, it is better to use the Python's parallelisation with threads or asyncio tasks.
Just as a rough idea:
Same for threads and regular
def
functions.The specific implementations are outside of the Kopf's scope, so this parallelisation pattern is not a part of it.
With
kopf>=0.23rc1
(see the release notes), the on-resume handlers are fixed in few aspects:See #230 for details.
I assume, the issue is fixed. The "parallel execution" issue is explained above — it never existed, and, perhaps, is just a terminology misunderstanding.
If the issue with the on-resume handlers continues to reappear in
>=0.23rc1
, feel free to re-open this issue with a describing comment (or at least just leave a comment).The text was updated successfully, but these errors were encountered: