modify
This commit is contained in:
@@ -77,10 +77,7 @@ class OnTask extends Callback
|
|||||||
if (empty($task->data)) {
|
if (empty($task->data)) {
|
||||||
return $task->finish('null data');
|
return $task->finish('null data');
|
||||||
}
|
}
|
||||||
$app = Snowflake::app();
|
|
||||||
$app->increment();
|
|
||||||
$finish = $this->runTaskHandler($task->data);
|
$finish = $this->runTaskHandler($task->data);
|
||||||
$app->decrement();
|
|
||||||
if (!$finish) {
|
if (!$finish) {
|
||||||
$finish = [];
|
$finish = [];
|
||||||
}
|
}
|
||||||
@@ -100,6 +97,7 @@ class OnTask extends Callback
|
|||||||
*/
|
*/
|
||||||
private function runTaskHandler($data): ?array
|
private function runTaskHandler($data): ?array
|
||||||
{
|
{
|
||||||
|
$app = Snowflake::app()->increment();
|
||||||
try {
|
try {
|
||||||
$serialize = $this->before($data);
|
$serialize = $this->before($data);
|
||||||
$params = $serialize->getParams();
|
$params = $serialize->getParams();
|
||||||
@@ -114,11 +112,13 @@ class OnTask extends Callback
|
|||||||
$finish['status'] = 'error';
|
$finish['status'] = 'error';
|
||||||
$finish['info'] = $this->format($exception);
|
$finish['info'] = $this->format($exception);
|
||||||
$this->error($exception, 'Task');
|
$this->error($exception, 'Task');
|
||||||
} finally {
|
}
|
||||||
|
$app->decrement();
|
||||||
|
|
||||||
$event = Snowflake::app()->getEvent();
|
$event = Snowflake::app()->getEvent();
|
||||||
$event->trigger(Event::SYSTEM_RESOURCE_CLEAN);
|
$event->trigger(Event::SYSTEM_RESOURCE_CLEAN);
|
||||||
Timer::clearAll();
|
Timer::clearAll();
|
||||||
}
|
|
||||||
return $finish;
|
return $finish;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -119,6 +119,8 @@ abstract class BaseApplication extends Service
|
|||||||
} else {
|
} else {
|
||||||
$this->state = 'SWOOLE_WORKER_BUSY';
|
$this->state = 'SWOOLE_WORKER_BUSY';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user