Skip to content

Commit

Permalink
pass test
Browse files Browse the repository at this point in the history
  • Loading branch information
baoj2010 committed Jun 30, 2022
1 parent 4b2b52f commit 3ca945d
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions bali/decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ def event_handler(event_type):
# find queue by event_type
def decorator(func):
@functools.wraps(func)
def wrapper(body, message):
def wrapper(handler, body, message):
try:
if isinstance(body, str):
body = json.loads(body)
Expand All @@ -175,13 +175,15 @@ def wrapper(body, message):
):
event = param.annotation(**body)
break
res = func(HANDLER, event or body)
if not handler:
handler = HANDLER
res = func(handler, event or body)
message.ack()
return res
except:
logger.error(traceback.format_exc())

register_callback(event_type, wrapper)
callback = functools.partial(wrapper, None)
register_callback(event_type, callback)
return wrapper

return decorator

0 comments on commit 3ca945d

Please sign in to comment.