Skip to content

Commit 3ca945d

Browse files
committed
pass test
1 parent 4b2b52f commit 3ca945d

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

bali/decorators.py

+6-4
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ def event_handler(event_type):
158158
# find queue by event_type
159159
def decorator(func):
160160
@functools.wraps(func)
161-
def wrapper(body, message):
161+
def wrapper(handler, body, message):
162162
try:
163163
if isinstance(body, str):
164164
body = json.loads(body)
@@ -175,13 +175,15 @@ def wrapper(body, message):
175175
):
176176
event = param.annotation(**body)
177177
break
178-
res = func(HANDLER, event or body)
178+
if not handler:
179+
handler = HANDLER
180+
res = func(handler, event or body)
179181
message.ack()
180182
return res
181183
except:
182184
logger.error(traceback.format_exc())
183-
184-
register_callback(event_type, wrapper)
185+
callback = functools.partial(wrapper, None)
186+
register_callback(event_type, callback)
185187
return wrapper
186188

187189
return decorator

0 commit comments

Comments
 (0)