Skip to content

Commit 3447952

Browse files
committed
[v0.1.8] add delay option between iterations
1 parent b19d84d commit 3447952

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

Console/Command/ThreadProcessorCommand.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,11 @@ protected function configure(): void
4141
'',
4242
InputOption::VALUE_OPTIONAL,
4343
'Define the number of iteration'
44+
)->addOption(
45+
'delay',
46+
'',
47+
InputOption::VALUE_OPTIONAL,
48+
'Define the delay in ms between each iteration'
4449
)->addOption(
4550
'environment',
4651
'env',
@@ -66,12 +71,12 @@ protected function execute(InputInterface $input, OutputInterface $output): int
6671
{
6772
// Argument and option
6873
$commandName = $input->getArgument('command_name');
69-
//$this->getApplication()->get($commandName);
7074

7175
$environment = $input->getOption('environment');
7276
$envExploded = !empty($environment) ? explode(',', $environment) : null;
7377
$timeout = (float)$input->getOption('timeout') ?: 300;
7478
$iterations = $input->getOption('iterations') ?: 0;
79+
$delay = (int)$input->getOption('delay') ?: 0;
7580

7681
// Build extra env values
7782
$arrayEnv = null;
@@ -113,6 +118,11 @@ protected function execute(InputInterface $input, OutputInterface $output): int
113118
break;
114119
}
115120

121+
// Delay between iterations in microseconds
122+
if ($delay > 0) {
123+
usleep($delay * 1000);
124+
}
125+
116126
// Run single thread process
117127
$process = new Process($command, BP, $arrayEnv);
118128
$process->setTimeout($timeout);

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "zepgram/module-multi-threading",
33
"description": "This module is a powerful tool for developers who want to process large data sets in a short amount of time",
44
"type": "magento2-module",
5-
"version": "0.1.7",
5+
"version": "0.1.8",
66
"authors": [
77
{
88
"name": "Benjamin Calef",

0 commit comments

Comments
 (0)