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
When k8s-event-posting was moved to a background task (#125), some asyncio-related tasks were made way to complicated (multiple dynamically created loggers) and implemented improperly (non-thread-safe put_nowait() when used across threads).
The non-thread-safeness made some k8s-events not posted as soon as it was possible, but waiting for few seconds until something happens on an asyncio event-loop (because put_nowait() does not wake up the event-loop). And it was failing of debug mode was used.
This has become important since #128 — as not only Kopf's internal routines, but also the sync-handlers (which run in a thread-pool) could log INFO+ messages, which should be posted to k8s.
This PR simplifies the solution to one and only one logger (and therefore one and only one handler), and by posting all k8s-events synchronously but instantly via one and only one function (enqueue()).
In that function (enqueue()), one of the thread-safe methods is used to put an event to a queue: either the same-threaded method (thread-safe by definition), or cross-threaded method (explicitly thread-safe).
Types of Changes
Refactor/improvements
The text was updated successfully, but these errors were encountered:
Part of an effort to make Kopf-based operators more stable and resilient.
Description
When k8s-event-posting was moved to a background task (#125), some asyncio-related tasks were made way to complicated (multiple dynamically created loggers) and implemented improperly (non-thread-safe
put_nowait()
when used across threads).The non-thread-safeness made some k8s-events not posted as soon as it was possible, but waiting for few seconds until something happens on an asyncio event-loop (because
put_nowait()
does not wake up the event-loop). And it was failing of debug mode was used.This has become important since #128 — as not only Kopf's internal routines, but also the sync-handlers (which run in a thread-pool) could log INFO+ messages, which should be posted to k8s.
This PR simplifies the solution to one and only one logger (and therefore one and only one handler), and by posting all k8s-events synchronously but instantly via one and only one function (
enqueue()
).In that function (
enqueue()
), one of the thread-safe methods is used to put an event to a queue: either the same-threaded method (thread-safe by definition), or cross-threaded method (explicitly thread-safe).Types of Changes
The text was updated successfully, but these errors were encountered: