Skip to content
New issue

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

added parameter specifying max. number processes run #25

Merged
merged 3 commits into from
Dec 15, 2019

Conversation

evanbiederstedt
Copy link
Collaborator

@evanbiederstedt evanbiederstedt commented Dec 12, 2019

Related to this issue: #23

I added an optional parameter to use, as opposed to the default value of 10 in the line while(scalar(keys %still_running) >= 10)

I set the default value to 2---please feel free to use a larger value of course!

Previously, the script had the following code:

https://github.com/NCBI-Hackathons/NovoGraph/blob/master/scripts/launch_CRAM2VCF_C%2B%2B.pl#L102-L116

my %still_running;

if($totalCommands == 0)
{
	print "\nAll done.\n\n";
}
else
{
	foreach my $iI (@indices)
	{
		my $command = $commands[$iI];
		while(scalar(keys %still_running) >= 10)
		{
			sleep 10;
		}
		
		my $pid = fork;
		die "fork failed" unless defined $pid;
		if ($pid == 0) {
			system($command) and die "Could not execute command: $command";
			exit;
		}		
		$still_running{$pid} = 1;			
	}
	
	print "\n\nProcesses launched.\n";
}

I also added a check to make sure it's a positive integer.

There's probably a better name for this parameter---please come up with something!

TDIL: I'm also fascinated that apparently the colon : in GetOptions specifies an optional argument: https://stackoverflow.com/questions/6555644/how-to-use-getoptions-utility-to-handle-optional-command-line-arguments-in-per

@evanbiederstedt evanbiederstedt changed the title added parameter specifying processes to be run added parameter specifying max. number processes to be simultaneously run Dec 12, 2019
@evanbiederstedt evanbiederstedt changed the title added parameter specifying max. number processes to be simultaneously run added parameter specifying max. number processes to be un Dec 12, 2019
@evanbiederstedt evanbiederstedt changed the title added parameter specifying max. number processes to be un added parameter specifying max. number processes run Dec 12, 2019
Copy link
Collaborator

@TorHou TorHou left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good 👍

@evanbiederstedt
Copy link
Collaborator Author

I'll merge away

@evanbiederstedt evanbiederstedt merged commit c81d678 into master Dec 15, 2019
@evanbiederstedt evanbiederstedt deleted the feature/add_param_still_running branch December 15, 2019 18:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants