Skip to content

Commit

Permalink
improve buffer checks
Browse files Browse the repository at this point in the history
  • Loading branch information
angus-langchain committed Dec 13, 2024
1 parent 0e06bde commit f997895
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion python/langsmith/_internal/_background_thread.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,16 @@ def _tracing_thread_drain_compressed_buffer(
with client._buffer_lock:
current_size = client.compressed_runs_buffer.tell()

if not (client._run_count >= size_limit or current_size >= size_limit_bytes):
if size_limit is not None and size_limit <= 0:
raise ValueError(f"size_limit must be positive; got {size_limit}")
if size_limit_bytes is not None and size_limit_bytes < 0:
raise ValueError(
f"size_limit_bytes must be nonnegative; got {size_limit_bytes}"
)

if (size_limit_bytes is None or current_size < size_limit_bytes) and (
size_limit is None or len(client._run_count) < size_limit
):
return None

# Write final boundary and close compression stream
Expand Down

0 comments on commit f997895

Please sign in to comment.