• Resolved Jack

    (@jack1132132)


    Hello,

    I’ve been stress testing posting multiple videos at the same time, having them encoded by videopack, and I’ve noticed an issue where if I called:
    wp_schedule_single_event( time() + $time_offset, 'kgvid_cron_new_attachment', array($post_id, $force) ); multiple times within the span of 10 seconds then some events wouldn’t be scheduled despite the function returning true.

    I don’t know if this could be related to my setup of calling wp-cron.php every minute through a cron job, as opposed to the default of calling it every page visit.
    But I’ve replaced the regular wordpress scheduling with the action scheduler library like this:

    function replace_wp_schedule_with_async_action_videopack($pre, $event, $wp_error){
    
    	switch($event->hook){
    
    		case 'kgvid_cron_new_attachment': 
    			as_schedule_single_action($event->timestamp, 'kgvid_cron_new_attachment', $event->args);
    			$pre = false;
    			break;
    		case 'kgvid_cron_queue_check': 
    			as_schedule_single_action($event->timestamp, 'kgvid_cron_queue_check', $event->args);
    			$pre = false;
    			break;
    		case 'kgvid_cron_replace_video_check': 
    			as_schedule_single_action($event->timestamp, 'kgvid_cron_replace_video_check', $event->args);
    			$pre = false;
    			break;
    		case 'kgvid_cron_check_post_parent': 
    			as_schedule_single_action($event->timestamp, 'kgvid_cron_check_post_parent', $event->args);
    			$pre = false;
    			break;
    		case 'kgvid_cleanup_generated_logfiles': 
    			as_schedule_single_action($event->timestamp, 'kgvid_cleanup_generated_logfiles', $event->args);
    			$pre = false;
    			break;
    		case 'kgvid_cleanup_generated_thumbnails': 
    			as_schedule_single_action($event->timestamp, 'kgvid_cleanup_generated_thumbnails', $event->args);
    			$pre = false;
    			break;
    	}
    
    	return $pre;
    }
    add_filter('pre_schedule_event', 'replace_wp_schedule_with_async_action_videopack', 99, 3);

    And not my issues are gone!



    Thank you.

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘Issues with the regular wordpress scheduling functions’ is closed to new replies.