Skip to content

Commit e5d0525

Browse files
fix: Add sleep to OTEL exporters (#51)
Infinite polling the export queue without a sleep was causing threads to take up a full core of CPU. Simple sleep fixes that.
1 parent 201fb95 commit e5d0525

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/humanloop/otel/exporter/__init__.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import logging
22

3+
import time
34
import typing
45
from queue import Empty as EmptyQueue
56
from queue import Queue
@@ -129,7 +130,8 @@ def _do_work(self):
129130
# Don't block or the thread will never be notified of the shutdown
130131
thread_args = self._upload_queue.get(block=False) # type: ignore
131132
except EmptyQueue:
132-
# Wait for the another span to arrive
133+
# Wait for another span to arrive
134+
time.sleep(0.1)
133135
continue
134136

135137
span_to_export, eval_context_callback = thread_args

0 commit comments

Comments
 (0)