Spawn a new environment in a given address as a coroutine.

    Arguments and keyword arguments are passed down to the created environment
    at initialization time.

    If `setproctitle <https://pypi.python.org/pypi/setproctitle>`_ is
    installed, this function renames the title of the process to start with
    'creamas' so that the process is easily identifiable, e.g. with
    ``ps -x | grep creamas``.

def spawn_container(addr, env_cls=Environment,
                    mgr_cls=EnvManager, set_seed=True, *args, **kwargs):
    """Spawn a new environment in a given address as a coroutine.

    Arguments and keyword arguments are passed down to the created environment
    at initialization time.

    If `setproctitle <https://pypi.python.org/pypi/setproctitle>`_ is
    installed, this function renames the title of the process to start with
    'creamas' so that the process is easily identifiable, e.g. with
    ``ps -x | grep creamas``.
    """
    # Try setting the process name to easily recognize the spawned
    # environments with 'ps -x' or 'top'
    try:
        import setproctitle as spt
        title = 'creamas: {}({})'.format(env_cls.__class__.__name__,
                                         _get_base_url(addr))
        spt.setproctitle(title)
    except:
        pass

    if set_seed:
        _set_random_seeds()

    # kwargs['codec'] = aiomas.MsgPack
    task = start(addr, env_cls, mgr_cls, *args, **kwargs)
    loop = asyncio.new_event_loop()
    asyncio.set_event_loop(loop)
    loop.run_until_complete(task)