Merged
Conversation
- Fix lease leak: when __execute_task returns None (ASYNC_TASK_RUNNING), keep the lease tracked instead of untracking in the finally block. Untrack in __check_completed_async_tasks when the async task finishes. - Remove dead isinstance(task_result, TaskInProgress) checks — __execute_task always wraps TaskInProgress into TaskResult before returning. - Add threading.Lock around _lease_info dict for PEP 703 free-threaded Python compatibility (safe beyond CPython GIL). - Log exception cause in _send_heartbeat retry failures (was swallowed). - Extract LeaseInfo dataclass and constants into shared lease_tracker.py module to eliminate duplication between task_runner and async_task_runner. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…395) RESTResponse now eagerly reads resp.text into self.data and breaks the httpx Response <-> BoundSyncStream cycle by nulling resp.stream and resp._request. Drops io.IOBase inheritance (removes __del__ finalizer overhead). Removes write-only self.last_response retention. Adds json(), getheader() convenience methods to RESTResponse. Changes applied to both sync (rest.py, api_client.py) and async (async_rest.py, async_api_client.py) codepaths. Fixes #395 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
.. |
nohup23
approved these changes
Apr 18, 2026
- Wrap resp._request = None in try/except AttributeError for forward compat with future httpx versions - Fix async_rest.py comment: BoundSyncStream → BoundAsyncStream - Fix test_task_runner_coverage.py mocks: use mock_http_resp.data instead of dead mock_http_resp.resp (AuthorizationException now reads .data, not .resp.text) Follow-up to #395 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
RESTResponseLease Extension
Workers can now opt into automatic lease extension so long-running tasks don't time out:
LeaseExtendWorkerbase class andlease_extend_enabledparameter on@worker_taskextendLeasebefore the current lease expiresMemory Leak Fix (Fixes #395)
Long-running worker processes experienced ~450 KB/min memory growth per subprocess due to three issues in the HTTP layer:
RESTResponsenow eagerly readsresp.textintoself.dataand breaks the cycle by nullingresp.stream/resp._requestRESTResponse(io.IOBase)retained full httpx.Response — droppedio.IOBaseinheritance, removing__del__finalizer overheadself.last_responsewrite-only retention — removed dead write that pinned the last response for the lifetime ofApiClientChanges applied to both sync (
rest.py,api_client.py) and async (async_rest.py,async_api_client.py) codepaths. Also fixed silently brokenAuthorizationExceptiontest mocks that were using the removed.respattribute.Test plan
test_memory_leak.py) — weakref-based test proving httpx.Response objects are GC-able after RESTResponse constructionrepro_memory_leak.py) — tracemalloc validation showing 11.7 KB growth over 2000 requests (vs ~450 KB/min before fix)AuthorizationExceptiontest mocks to use.datainstead of dead.respattribute🤖 Generated with Claude Code