Skip to content
This repository has been archived by the owner on Dec 15, 2021. It is now read-only.

Commit

Permalink
Merge pull request #51 from icon-project/feature/LC-107
Browse files Browse the repository at this point in the history
[LC-107] apply subscribe event to rest call
  • Loading branch information
laurenceyoon committed Jan 3, 2019
2 parents 9271e06 + c267cf4 commit 42ac80e
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions loopchain/channel/channel_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -486,9 +486,9 @@ async def __subscribe_call_to_stub(self, peer_stub, peer_type):

async def __subscribe_call_from_citizen(self):
def _handle_exception(future: asyncio.Future):
logging.debug("error" + str(future.exception()))
logging.debug(f"error: {type(future.exception())}, {str(future.exception())}")
if isinstance(future.exception(), NotImplementedError):
asyncio.ensure_future(self.__subscribe_call_by_rest_stub())
asyncio.ensure_future(self.__subscribe_call_by_rest_stub(subscribe_event))

elif isinstance(future.exception(), ConnectionError):
logging.warning(f"Waiting for next subscribe request...")
Expand All @@ -505,7 +505,7 @@ def _handle_exception(future: asyncio.Future):
)).add_done_callback(_handle_exception)
await subscribe_event.wait()

async def __subscribe_call_by_rest_stub(self):
async def __subscribe_call_by_rest_stub(self, event):
if conf.REST_SSL_TYPE == conf.SSLAuthType.none:
peer_target = ChannelProperty().rest_target
else:
Expand All @@ -526,6 +526,7 @@ async def __subscribe_call_by_rest_stub(self):

if response and response['response_code'] == message_code.Response.success:
logging.debug(f"Subscription to RadioStation(mother peer) is successful.")
event.set()
self.start_check_last_block_rs_timer()

def __check_last_block_to_rs(self):
Expand Down

0 comments on commit 42ac80e

Please sign in to comment.