Skip to content

Commit 23e1301

Browse files
committed
Fix: get event loop instead of create
We used to create a new event loop in each sync instance, which is silly and can error.
1 parent 67c62ec commit 23e1301

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

src/obelisk/sync/consumer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def __init__(self, client: str, secret: str,
2929
retry_strategy: RetryStrategy = NoRetryStrategy(),
3030
kind: ObeliskKind = ObeliskKind.CLASSIC):
3131
self.async_consumer = AsyncConsumer(client, secret, retry_strategy, kind)
32-
self.loop = asyncio.new_event_loop()
32+
self.loop = asyncio.get_event_loop()
3333

3434
def single_chunk(self, datasets: List[str], metrics: List[str] | None = None,
3535
fields: dict | None = None,

src/obelisk/sync/producer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ def __init__(self, client: str, secret: str,
2424
retry_strategy: RetryStrategy = NoRetryStrategy(),
2525
kind: ObeliskKind = ObeliskKind.CLASSIC):
2626
self.async_producer = AsyncProducer(client, secret, retry_strategy, kind)
27-
self.loop = asyncio.new_event_loop()
27+
self.loop = asyncio.get_event_loop()
2828

2929
def send(self, dataset: str, data: List[dict],
3030
precision: TimestampPrecision = TimestampPrecision.MILLISECONDS,

0 commit comments

Comments
 (0)