# Path: osim/redis/messages.py
# class OSIM_RL:
#     PING = "OSIM_RL.PING"
#     PONG = "OSIM_RL.PONG"
#     ENV_CREATE = "OSIM_RL.ENV_CREATE"
#     ENV_CREATE_RESPONSE = "OSIM_RL.ENV_CREATE_RESPONSE"
#     ENV_RESET = "OSIM_RL.ENV_RESET"
#     ENV_RESET_RESPONSE = "OSIM_RL.ENV_RESET_RESPONSE"
#     ENV_STEP = "OSIM_RL.ENV_STEP"
#     ENV_STEP_RESPONSE = "OSIM_RL.ENV_STEP_RESPONSE"
#     ENV_SUBMIT = "OSIM_RL.ENV_SUBMIT"
#     ENV_SUBMIT_RESPONSE = "OSIM_RL.ENV_SUBMIT_RESPONSE"
#     ERROR = "OSIM_RL.ERROR"


import redis
import json
import os
import pkg_resources
import sys
import numpy as np
import msgpack
import msgpack_numpy as m
import hashlib
import random
import time
import logging
from osim.redis import messages

    def _blocking_request(self, _request):
        """
            request:
                -command_type
                -payload
                -response_channel
            response: (on response_channel)
                - RESULT
            * Send the payload on command_channel (self.namespace+"::command")
                ** redis-left-push (LPUSH)
            * Keep listening on response_channel (BLPOP)
        """
        assert type(_request) ==type({})
        _request['response_channel'] = self._generate_response_channel()

        _redis = self.get_redis_connection()
        """
            The client always pushes in the left
            and the service always pushes in the right
        """
        if self.verbose: print("Request : ", _response)
        # Push request in command_channels
        payload = msgpack.packb(_request, default=m.encode, use_bin_type=True)
        _redis.lpush(self.command_channel, payload)
        ## TODO: Check if we can use `repr` for json.dumps string serialization
        # Wait with a blocking pop for the response
        _response = _redis.blpop(_request['response_channel'])[1]
        if self.verbose: print("Response : ", _response)
        _response = msgpack.unpackb(_response, object_hook=m.decode, encoding="utf8")

# Path: osim/redis/messages.py
# class OSIM_RL:
#     PING = "OSIM_RL.PING"
#     PONG = "OSIM_RL.PONG"
#     ENV_CREATE = "OSIM_RL.ENV_CREATE"
#     ENV_CREATE_RESPONSE = "OSIM_RL.ENV_CREATE_RESPONSE"
#     ENV_RESET = "OSIM_RL.ENV_RESET"
#     ENV_RESET_RESPONSE = "OSIM_RL.ENV_RESET_RESPONSE"
#     ENV_STEP = "OSIM_RL.ENV_STEP"
#     ENV_STEP_RESPONSE = "OSIM_RL.ENV_STEP_RESPONSE"
#     ENV_SUBMIT = "OSIM_RL.ENV_SUBMIT"
#     ENV_SUBMIT_RESPONSE = "OSIM_RL.ENV_SUBMIT_RESPONSE"
#     ERROR = "OSIM_RL.ERROR"


# Path: osim/redis/client.py
import redis
import json
import os
import pkg_resources
import sys
import numpy as np
import msgpack
import msgpack_numpy as m
import hashlib
import random
import time
import logging
from osim.redis import messages


    def _blocking_request(self, _request):
        """
            request:
                -command_type
                -payload
                -response_channel
            response: (on response_channel)
                - RESULT
            * Send the payload on command_channel (self.namespace+"::command")
                ** redis-left-push (LPUSH)
            * Keep listening on response_channel (BLPOP)
        """
        assert type(_request) ==type({})
        _request['response_channel'] = self._generate_response_channel()

        _redis = self.get_redis_connection()
        """
            The client always pushes in the left
            and the service always pushes in the right
        """
        if self.verbose: print("Request : ", _response)
        # Push request in command_channels
        payload = msgpack.packb(_request, default=m.encode, use_bin_type=True)
        _redis.lpush(self.command_channel, payload)
        ## TODO: Check if we can use `repr` for json.dumps string serialization
        # Wait with a blocking pop for the response
        _response = _redis.blpop(_request['response_channel'])[1]
        if self.verbose: print("Response : ", _response)
        _response = msgpack.unpackb(_response, object_hook=m.decode, encoding="utf8")

        if _response['type'] == messages.OSIM_RL.ERROR: