# Path: pyactor/exceptions.py
# class PyActorTimeoutError(Exception):
#     """Wait time expired."""
# 
#     def __init__(self, method='Not specified'):
#         self.method = method
# 
#     def __str__(self):
#         return f"Timeout triggered: {self.method!r}"
# 
# class HostError(Exception):
#     """Some problem with the Host."""
# 
#     def __init__(self, value='Not specified'):
#         self.value = value
# 
#     def __str__(self):
#         return f"Host ERROR: {self.value!r}"
# 
# Path: pyactor/util.py
# ASK = 'ASK'
# 
# TELL = 'TELL'
# 
# TYPE = 'TYPE'
# 
# METHOD = 'METHOD'
# 
# PARAMS = 'PARAMS'
# 
# CHANNEL = 'CHANNEL'
# 
# TO = 'TO'
# 
# RESULT = 'RESULT'
# 
# Path: pyactor/util.py
# def get_host():
#     if core_type == 'thread':
#         current = current_thread()
#     else:
#         current = getcurrent()
#     for host in hosts.values():
#         if current in host.threads.keys():
#             return host
#         elif current in host.pthreads.keys():
#             return host
#     return main_host
# 
# def get_lock():
#     if core_type == 'thread':
#         current = current_thread()
#     else:
#         return None
#     url = None
#     for host in hosts.values():
#         if current in host.threads.keys():
#             url = host.threads[current]
#         elif current in host.pthreads.keys():
#             url = host.pthreads[current]
#         if url in host.locks.keys():
#             lock = host.locks[url]
#             return lock
# 
# def get_current():
#     if core_type == 'thread':
#         current = current_thread()
#     else:
#         current = getcurrent()
#     for host in hosts.values():
#         if current in host.threads.keys():
#             return host.actors[host.threads[current]]
#         elif current in host.pthreads.keys():
#             return host.actors[host.pthreads[current]]


from importlib import import_module
from queue import Empty
from .exceptions import PyActorTimeoutError, HostError
from .util import ASK, TELL, TYPE, METHOD, PARAMS, CHANNEL, TO, RESULT
from .util import get_host, get_lock, get_current
        self.__lock = get_lock()
        if not future:
            self.__channel = actor_channel.Channel()
            if 'timeout' in kwargs.keys():
                timeout = kwargs['timeout']
                del kwargs['timeout']
            else:
                timeout = 10
            #  SENDING MESSAGE ASK
            # msg = AskRequest(ASK, self._method, args, self.__channel,
            #                  self.target)
            msg = {TYPE: ASK, METHOD: self._method, PARAMS: (args, kwargs),
                   CHANNEL: self.__channel, TO: self.target}
            self._actor_channel.send(msg)
            if self.__lock is not None:
                self.__lock.release()
            try:
                response = self.__channel.receive(timeout)
                result = response[RESULT]
            except Empty:
                if self.__lock is not None:
                    self.__lock.acquire()
                raise PyActorTimeoutError(self._method)
            if self.__lock is not None:
                self.__lock.acquire()
            if isinstance(result, Exception):
                raise result
            else:
                return result
        else:

# Path: pyactor/exceptions.py
# class PyActorTimeoutError(Exception):
#     """Wait time expired."""
# 
#     def __init__(self, method='Not specified'):
#         self.method = method
# 
#     def __str__(self):
#         return f"Timeout triggered: {self.method!r}"
# 
# class HostError(Exception):
#     """Some problem with the Host."""
# 
#     def __init__(self, value='Not specified'):
#         self.value = value
# 
#     def __str__(self):
#         return f"Host ERROR: {self.value!r}"
# 
# Path: pyactor/util.py
# ASK = 'ASK'
# 
# TELL = 'TELL'
# 
# TYPE = 'TYPE'
# 
# METHOD = 'METHOD'
# 
# PARAMS = 'PARAMS'
# 
# CHANNEL = 'CHANNEL'
# 
# TO = 'TO'
# 
# RESULT = 'RESULT'
# 
# Path: pyactor/util.py
# def get_host():
#     if core_type == 'thread':
#         current = current_thread()
#     else:
#         current = getcurrent()
#     for host in hosts.values():
#         if current in host.threads.keys():
#             return host
#         elif current in host.pthreads.keys():
#             return host
#     return main_host
# 
# def get_lock():
#     if core_type == 'thread':
#         current = current_thread()
#     else:
#         return None
#     url = None
#     for host in hosts.values():
#         if current in host.threads.keys():
#             url = host.threads[current]
#         elif current in host.pthreads.keys():
#             url = host.pthreads[current]
#         if url in host.locks.keys():
#             lock = host.locks[url]
#             return lock
# 
# def get_current():
#     if core_type == 'thread':
#         current = current_thread()
#     else:
#         current = getcurrent()
#     for host in hosts.values():
#         if current in host.threads.keys():
#             return host.actors[host.threads[current]]
#         elif current in host.pthreads.keys():
#             return host.actors[host.pthreads[current]]


# Path: pyactor/proxy.py
from importlib import import_module
from queue import Empty
from .exceptions import PyActorTimeoutError, HostError
from .util import ASK, TELL, TYPE, METHOD, PARAMS, CHANNEL, TO, RESULT
from .util import get_host, get_lock, get_current

        self.__lock = get_lock()
        if not future:
            self.__channel = actor_channel.Channel()
            if 'timeout' in kwargs.keys():
                timeout = kwargs['timeout']
                del kwargs['timeout']
            else:
                timeout = 10
            #  SENDING MESSAGE ASK
            # msg = AskRequest(ASK, self._method, args, self.__channel,
            #                  self.target)
            msg = {TYPE: ASK, METHOD: self._method, PARAMS: (args, kwargs),
                   CHANNEL: self.__channel, TO: self.target}
            self._actor_channel.send(msg)
            if self.__lock is not None:
                self.__lock.release()
            try:
                response = self.__channel.receive(timeout)
                result = response[RESULT]
            except Empty:
                if self.__lock is not None:
                    self.__lock.acquire()
                raise PyActorTimeoutError(self._method)
            if self.__lock is not None:
                self.__lock.acquire()
            if isinstance(result, Exception):
                raise result
            else:
                return result
        else:

            future_ref = {METHOD: self._method, PARAMS: (args, kwargs),