Skip to content

Commit

Permalink
Fixes issue with AMQP transport and reverts old invalid commit
Browse files Browse the repository at this point in the history
  • Loading branch information
kalaspuff committed Aug 5, 2017
1 parent ea7cad3 commit 6103ca9
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
1 change: 0 additions & 1 deletion examples/amqp_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ class ExampleAmqpService(object):

@amqp('example.route1')
async def route1a(self, data: Any) -> None:
banana = True
self.logger.info('Received data (function: route1a) - "{}"'.format(data))

@amqp('example.route1')
Expand Down
4 changes: 3 additions & 1 deletion tomodachi/transport/amqp.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import re
import binascii
import asyncio
import inspect
from typing import Any, Dict, Union, Optional, Callable, Awaitable, Match
from tomodachi.invoker import Invoker

Expand Down Expand Up @@ -102,7 +103,8 @@ async def subscribe_handler(cls: Any, obj: Any, context: Dict, func: Any, routin
async def handler(payload: Any, delivery_tag: Any) -> Any:
_callback_kwargs = callback_kwargs # type: Any
if not _callback_kwargs:
_callback_kwargs = {k: func.__defaults__[len(func.__defaults__) - len(func.__code__.co_varnames[1:]) + i] if func.__defaults__ and len(func.__defaults__) - len(func.__code__.co_varnames[1:]) + i >= 0 else None for i, k in enumerate(func.__code__.co_varnames[1:])}
values = inspect.getfullargspec(func)
_callback_kwargs = {k: values.defaults[i - len(values.args) + 1] if values.defaults and i >= len(values.args) - len(values.defaults) - 1 else None for i, k in enumerate(values.args[1:])} if values.args and len(values.args) > 1 else {}
else:
_callback_kwargs = {k: None for k in _callback_kwargs if k != 'self'}
kwargs = {k: v for k, v in _callback_kwargs.items()}
Expand Down

0 comments on commit 6103ca9

Please sign in to comment.