Home » Php » Script gets stopped when using closures in pthreads

Script gets stopped when using closures in pthreads

Posted by: admin September 25, 2018 Leave a comment

Questions:

I use pthreads extension. PHP 7. windows 7 x64. When I try use closure in the Thread script suddenly died. It’s concole script, console just closed without any errors. Without closures it works.

This is part of my code:

class AccountsChecking extends \Thread
{
    public function run()
    {
        $cfg = new \Spot\Config();
        $cfg->addConnection('mysql', Config::$db_config);
        $spot = new \Spot\Locator($cfg);

        /** @var AccountRepository $accountRepository */
        $accountRepository = $spot->mapper(Account::class);
        /** @var ProxyRepository $proxyRepository */
        $proxyRepository = $spot->mapper(Proxy::class);
        /** @var InterceptedMailRepository $interceptedMailRepository */
        $interceptedMailRepository = $spot->mapper(InterceptedMail::class);
        /** @var FilterTypeRepository $filterTypeRepository */
        $filterTypeRepository = $spot->mapper(FilterType::class);
        /** @var FileRepository $fileRepository */
        $fileRepository = $spot->mapper(File::class);
        /** @var SystemLogRepository $systemLogRepository */
        $systemLogRepository = $spot->mapper(SystemLog::class);
        /** @var StatisticRepository $statisticRepository */
        $statisticRepository = $spot->mapper(Statistic::class);
        /** @var KeyStorageItemRepository $keyStorageItemRepository */
        $keyStorageItemRepository = $spot->mapper(KeyStorageItem::class);

        $statisticService = new StatisticService($keyStorageItemRepository, $statisticRepository);

        $proxies = $proxyRepository->getEnabled();
        $whiteFilters = $filterTypeRepository->getEnabledWhiteFilters();
        $blackFilters = $filterTypeRepository->getEnabledBlackFilters();

        /** @var AccountDataProvider $provider */
        $provider = $this->worker->getProvider();

        $imapService = new ImapService($proxies, $whiteFilters, $blackFilters);

        $imapService->setEventHandler('chilkatLicenseFailed', function ($params) use ($systemLogRepository) {
            $systemLogRepository->writeLog($params['error_text']);
        });
}
}

In other computer with same windows, php it’s works!

I don’t have any ideas!

Answers: