Farama-Foundation / SuperSuit

A collection of wrappers for Gymnasium and PettingZoo environments (being merged into gymnasium.wrappers and pettingzoo.wrappers
Other
446 stars 56 forks source link

`concat_vec_envs_v1` prevents Python scripts from exiting #170

Closed timf34 closed 1 year ago

timf34 commented 2 years ago

Hi,

When I use concat_vec_envs_v1 when initializing my environment, the Python script will not exit.

Even when I call env.close() at the end of the script, and use sys.exit() or similar, it still will not exit.

Is there anything in particular I need to call to exit the script? Is this known to be an issue?

Thanks Tim

jjshoots commented 2 years ago

Hi @timf34, this may be an artifact from the fact that concat_vec_env uses parallel processing in Python. I think you'd need to perform a SIGINT catch:

from signal import SIGINT, signal

def shutdown_handler(*_):
    print("ctrl-c invoked")
    exit(0)

if __name__ == "__main__":
    signal(SIGINT, shutdown_handler)
    ...
timf34 commented 2 years ago

This unfortunately doesn't seem to work

jjshoots commented 2 years ago

@benblack769 Could you perhaps have a look?