当前位置: 首页>>代码示例>>PHP>>正文


PHP eZDB::setErrorHandling方法代码示例

本文整理汇总了PHP中eZDB::setErrorHandling方法的典型用法代码示例。如果您正苦于以下问题:PHP eZDB::setErrorHandling方法的具体用法?PHP eZDB::setErrorHandling怎么用?PHP eZDB::setErrorHandling使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在eZDB的用法示例。


在下文中一共展示了eZDB::setErrorHandling方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: run

    /**
     * Main method: infinite method that monitors queued objects, and starts
     * the publishinbg processes if allowed
     *
     * @return void
     */
    public function run()
    {
        // use DB exceptions so that errors can be fully handled
        eZDB::setErrorHandling( eZDB::ERROR_HANDLING_EXCEPTIONS );

        $this->cleanupDeadProcesses();

        while ( $this->canProcess )
        {
            try {
                /**
                 * @var ezpContentPublishingProcess
                 */
                $publishingItem = call_user_func( array( $this->queueReader, 'next' ) );
                if ( $publishingItem !== false )
                {
                    if ( !$this->isSlotAvailable() )
                    {
                        $this->out->write( "No slot is available", 'async.log' );
                        sleep ( 1 );
                        continue;
                    }
                    else
                    {
                        $this->out->write( "Processing item #" . $publishingItem->attribute( 'ezcontentobject_version_id' ), 'async.log' );
                        $pid = $publishingItem->publish();
                        pcntl_signal( SIGINT, $this->signalHandler );
                        $this->currentJobs[$pid] = $publishingItem;

                        // In the event that a signal for this pid was caught before we get here, it will be in our
                        // signalQueue array
                        // Process it now as if we'd just received the signal
                        if( isset( $this->signalQueue[$pid] ) )
                        {
                            $this->out->write( "found $pid in the signal queue, processing it now" );
                            $this->childSignalHandler( SIGCHLD, $pid, $this->signalQueue[$pid] );
                            unset( $this->signalQueue[$pid] );
                        }
                    }
                }
                else
                {
                    sleep( $this->sleepInterval );
                }
            } catch ( eZDBException $e ) {
                $this->out->write( "Database error #" . $e->getCode() . ": " . $e->getMessage() );
                // force the DB connection closed so that it is recreated
                try {
                    $db = eZDB::instance();
                    $db->close();
                    $db = null;
                    eZDB::setInstance( null );
                } catch( eZDBException $e ) {
                    // Do nothing, this will be retried until the DB is back up
                }
                sleep( 1 );
            }
        }
    }
开发者ID:sushilbshinde,项目名称:ezpublish-study,代码行数:65,代码来源:ezpcontentpublishingqueueprocessor.php


注:本文中的eZDB::setErrorHandling方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。