Skip to content

Commit

Permalink
Cleaned up code
Browse files Browse the repository at this point in the history
  • Loading branch information
kalaspuff committed Jul 2, 2017
1 parent acc5352 commit 58d2ab8
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 24 deletions.
5 changes: 1 addition & 4 deletions tomodachi/transport/amqp.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,10 +209,7 @@ async def connect(cls: Any, obj: Any, context: Dict) -> Any:

channel = await protocol.channel()
if not cls.channel:
try:
stop_method = getattr(obj, '_stop_service')
except AttributeError as e:
stop_method = None
stop_method = getattr(obj, '_stop_service', None)
async def stop_service(*args: Any, **kwargs: Any) -> None:
if stop_method:
await stop_method(*args, **kwargs)
Expand Down
10 changes: 2 additions & 8 deletions tomodachi/transport/aws_sns_sqs.py
Original file line number Diff line number Diff line change
Expand Up @@ -508,10 +508,7 @@ async def _callback() -> None:

loop = asyncio.get_event_loop() # type: Any

try:
stop_method = getattr(obj, '_stop_service')
except AttributeError as e:
stop_method = None
stop_method = getattr(obj, '_stop_service', None)
async def stop_service(*args: Any, **kwargs: Any) -> None:
if not cls.close_waiter.done():
cls.close_waiter.set_result(None)
Expand Down Expand Up @@ -563,10 +560,7 @@ async def stop_service(*args: Any, **kwargs: Any) -> None:

setattr(obj, '_stop_service', stop_service)

try:
started_method = getattr(obj, '_started_service')
except AttributeError as e:
started_method = None
started_method = getattr(obj, '_started_service', None)
async def started_service(*args: Any, **kwargs: Any) -> None:
if started_method:
await started_method(*args, **kwargs)
Expand Down
5 changes: 1 addition & 4 deletions tomodachi/transport/http.py
Original file line number Diff line number Diff line change
Expand Up @@ -353,10 +353,7 @@ async def func() -> web.Response:
port = int(server.sockets[0].getsockname()[1])
context['_http_port'] = port

try:
stop_method = getattr(obj, '_stop_service')
except AttributeError as e:
stop_method = None
stop_method = getattr(obj, '_stop_service', None)
async def stop_service(*args: Any, **kwargs: Any) -> None:
if stop_method:
await stop_method(*args, **kwargs)
Expand Down
10 changes: 2 additions & 8 deletions tomodachi/transport/schedule.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,10 +166,7 @@ async def schedule_loop() -> None:

loop = asyncio.get_event_loop() # type: Any

try:
stop_method = getattr(obj, '_stop_service')
except AttributeError as e:
stop_method = None
stop_method = getattr(obj, '_stop_service', None)
async def stop_service(*args: Any, **kwargs: Any) -> None:
if not cls.close_waiter.done():
cls.close_waiter.set_result(None)
Expand All @@ -186,10 +183,7 @@ async def stop_service(*args: Any, **kwargs: Any) -> None:

setattr(obj, '_stop_service', stop_service)

try:
started_method = getattr(obj, '_started_service')
except AttributeError as e:
started_method = None
started_method = getattr(obj, '_started_service', None)
async def started_service(*args: Any, **kwargs: Any) -> None:
if started_method:
await started_method(*args, **kwargs)
Expand Down

0 comments on commit 58d2ab8

Please sign in to comment.