Giter Site home page Giter Site logo

Comments (2)

richard-kelly avatar richard-kelly commented on July 24, 2024

Thanks for creating the test code. I am able to reproduce this in your test if I take out the python and just try to run a batch file that prints the time. I'm going to look into why it fails a bit more before putting in a fix.

from starcraftaitournamentmanager.

richard-kelly avatar richard-kelly commented on July 24, 2024

I changed the test code (see below) to print out the error stream from the process (only on even calls, otherwise the delay prevents the error) and found that the error message was:

"The process cannot access the file because it is being used by another process."

I thought this meant the problem was too many calls to access the same batch file, but if I use two different batch files for each pair of runs the problem still happens. If you change the code to produce 200 unique output files it will successfully create all of them. I believe the issue we're seeing with the test is just multiple processes trying to write to the same output file.

I don't know what the actual problem happening in the Tournament Manager is, then, since the process to run "run_proxy.bat" is only created once. The only other process created before that in the startStarCraft() method is one that renames the character files (ClientCommands.Client_RenameCharacterFile()).

Could you try adding some similar code to log the error message (if any) in your actual bot setup?

And did I understand correctly that adding the 10ms delay stopped the crashes completely?

public class Main{
	public synchronized static void runCommand(int id, boolean printErrors){
		try
		{
			String idString=Integer.toString(id+1);
			String command="D:\\test\\AI\\run_proxy.bat";
			String windowsCommandPrefix = "CMD /C ";
			String completeCommand = windowsCommandPrefix + command;
			System.out.println("\n" + idString+ " "+ completeCommand);
			Process proc = Runtime.getRuntime().exec(windowsCommandPrefix + command);
			if (printErrors) {
				BufferedReader br = new BufferedReader (new InputStreamReader(proc.getErrorStream()));
				String line;
				if ((line = br.readLine())!= null) { //or while to print multiple lines
					System.out.println(line); //log to a file instead?
				}
			}
			//Thread.sleep(10);
		}
		catch (Exception e)
		{
			e.printStackTrace();
		}
	}

	public static void main(String[] args){
		try{
			for(int i=0;i<100;i++){
				runCommand(i, false);
				runCommand(i, true);
				//Thread.sleep(2);
			}
		}catch (Exception e)
		{
			e.printStackTrace();
		}
	}
}

from starcraftaitournamentmanager.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.