We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
It seems that render() works even inside a thread. Just remember to get rid of the exception by removing the following lines:
render()
nes-py/nes_py/_image_viewer.py
Lines 25 to 28 in b6f4e26
A sample code is shown below:
import os os.environ['OMP_NUM_THREADS'] = '1' import threading import gym_super_mario_bros from gym_super_mario_bros.actions import SIMPLE_MOVEMENT from nes_py.wrappers import JoypadSpace def dummy_fun(steps): import numpy as np rng = np.random.default_rng(steps) sum = 0.0 for _ in range(steps): rfloat = rng.random() sum += rfloat print(f'sum {sum}') def do_something(steps): print('inside do_something') env = JoypadSpace(gym_super_mario_bros.make('SuperMarioBros-1-1-v0', new_step_api=False), SIMPLE_MOVEMENT) done = True for _ in range(steps): if done: state = env.reset() state, reward, done, info = env.step(env.action_space.sample()) env.render() print(f'state shape {state.shape}') env.close() def main(): steps = 5000 thread1 = threading.Thread( target=dummy_fun, args=( steps, ), ) thread1.start() thread2 = threading.Thread( target=do_something, args=( steps, ), ) thread2.start() thread1.join() thread2.join() if __name__ == '__main__': main()
Below is the screenshot:
The text was updated successfully, but these errors were encountered:
I created a pull request. let me know if additional checking is required: #92
Sorry, something went wrong.
No branches or pull requests
It seems that
render()
works even inside a thread. Just remember to get rid of the exception by removing the following lines:nes-py/nes_py/_image_viewer.py
Lines 25 to 28 in b6f4e26
A sample code is shown below:
Below is the screenshot:
![Screenshot](https://user-images.githubusercontent.com/1439011/230899865-4a78a0a2-78f9-4239-ad35-87ae3429211c.png)
The text was updated successfully, but these errors were encountered: