Skip to content

consider task dependencies on shutdown#1110

Closed
asteven wants to merge 1 commit intonolar:mainfrom
asteven:cleaner_shutdown
Closed

consider task dependencies on shutdown#1110
asteven wants to merge 1 commit intonolar:mainfrom
asteven:cleaner_shutdown

Conversation

@asteven
Copy link
Copy Markdown
Contributor

@asteven asteven commented Mar 18, 2024

The "credentials retriever" should not be stopped before other tasks, that depend on valid credentials, have been stopped.

closes: #1033

The "credentials retriever" should not be stopped before other
tasks, that depend on valid credentials, have been stopped.

Signed-off-by: Steven Armstrong <steven@armstrong.cc>
@asteven asteven requested a review from nolar as a code owner March 18, 2024 16:30
@nolar
Copy link
Copy Markdown
Owner

nolar commented Mar 20, 2026

A note mainly for self:

I see the stated problem — indeed, a problem. However, this solution is problematic too. spawn_tasks() and run_tasks() are a part of the public interface of Kopf (kopf/__init__.py). This change alters the declared signatures, thus breaks the backwards compatibility, therefore requires a semantic v2 release, which is not planned.

I need to try some other approaches prioritising or linking tasks.

  1. One way that I see is inheriting from asyncio.Task and adding a few fields with priorities/dependencies. However, the Task is a C-level unit, not pure Python, so some optimizations can be lost by inheriting it (as with dicts/ints/strs/etc).

  2. Another way is to inject hidden attributes, but this behaviour is not documented, so it is not clear how it behaves with optmized event loops (e.g., uvloop), maybe with slots.

These are the thoughts to the moment. Maybe I will come up with some other ideas later.

@nolar
Copy link
Copy Markdown
Owner

nolar commented Mar 20, 2026

I am closing this PR in favour of the newer one — which seemingly solves the same problem the same way (more or less), but without breaking changes, and using the StdLib's functionality (no hacks).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

peering depends on 'Credentials retriever' task but on shutdown that is stopped sooner

2 participants