minerl icon indicating copy to clipboard operation
minerl copied to clipboard

Process-safe launching of minecraft instance to solve creating multiple minerl environments in parallel

Open juliusfrost opened this issue 5 years ago • 8 comments

Adds a simple thread lock to prevent multiple processes from accessing the launch script. This prevents gradle build errors when trying to create multiple minerl environments in parallel. This passes asynchronous creation in #334 with the help of #351

juliusfrost avatar Jul 13 '20 04:07 juliusfrost

Does this require waiting for one instance to lock then launching the next?

minerllabs avatar Jul 13 '20 06:07 minerllabs

@minerllabs Yes, one thread acquires the lock first, then other threads wait in a queue to acquire the lock after the first one exits. There could be a way to narrow the scope of the lock period, but so far as I see it, there isn't a good way as the logic is controlled in the Minecraft client. But in practice, I didn't see much of an issue with the locking, other than it taking a while to launch all of the environments.

juliusfrost avatar Jul 13 '20 13:07 juliusfrost

I found that this solution doesn't work with certain multiprocessing techniques to parallelize the environments, such as in RLlib. So this pull might not be the best to merge yet. I'll be looking into this.

juliusfrost avatar Jul 13 '20 18:07 juliusfrost

Hello @juliusfrost! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found:

Line 51:80: E501 line too long (84 > 79 characters)

Comment last updated at 2020-07-14 20:43:18 UTC

pep8speaks avatar Jul 14 '20 20:07 pep8speaks

@MadcowD @minerllabs What should be done further to merge this?

juliusfrost avatar Aug 05 '20 16:08 juliusfrost

Hey this would be nice to have @MadcowD @minerllabs. Can we approve this PR?

neevparikh avatar Dec 23 '20 22:12 neevparikh

Any update on this?

danijar avatar Dec 03 '21 21:12 danijar

This seems to have been fixed in the latest version. At least this test script runs fine (but for some reason runs slow on my machine, even with a single environment. Might be my mangled environments). Parallel instances do not work on Windows, tho.

Miffyli avatar Dec 04 '21 10:12 Miffyli