Skip to content

Commit 9b0b797

Browse files
authored
Fix decorator bug. (#41)
Change-Id: I8cd52316709595f503a5da7477e9a1710f30a05a
1 parent f6d433b commit 9b0b797

4 files changed

Lines changed: 376 additions & 8 deletions

File tree

cozeloop/decorator/decorator.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,7 @@ def sync_wrapper(*args: Any, **kwargs: Any):
101101
span.set_tags(tags)
102102
span.finish()
103103

104-
if res:
105-
return res
104+
return res
106105

107106
@wraps(func)
108107
async def async_wrapper(*args: Any, **kwargs: Any):
@@ -140,8 +139,7 @@ async def async_wrapper(*args: Any, **kwargs: Any):
140139
span.set_tags(tags)
141140
span.finish()
142141

143-
if res:
144-
return res
142+
return res
145143

146144
@wraps(func)
147145
def gen_wrapper(*args: Any, **kwargs: Any):
@@ -249,7 +247,7 @@ def sync_stream_wrapper(*args: Any, **kwargs: Any):
249247
span.set_input(input)
250248
span.set_tags(tags)
251249

252-
if not hasattr(res, "__iter__") and res:
250+
if not hasattr(res, "__iter__"):
253251
return res
254252

255253
@wraps(func)
@@ -288,7 +286,7 @@ async def async_stream_wrapper(*args: Any, **kwargs: Any):
288286
span.set_input(input)
289287
span.set_tags(tags)
290288

291-
if not hasattr(res, "__aiter__") and res:
289+
if not hasattr(res, "__aiter__"):
292290
return res
293291

294292
if is_async_gen_func(func):
@@ -449,7 +447,7 @@ async def __async_streamer__(
449447
self.__span.set_start_time_first_resp(time.time_ns() // 1_000)
450448
self.__is_set_start_time_first_token = True
451449
yield s
452-
except StopIteration:
450+
except (StopIteration, StopAsyncIteration):
453451
pass
454452

455453

cozeloop/internal/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
# Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
22
# SPDX-License-Identifier: MIT
33

4-
VERSION = 'v0.1.21'
4+
VERSION = 'v0.1.22'

tests/decorator/__init__.py

Whitespace-only changes.

0 commit comments

Comments
 (0)