public IActionResult ManuallyRequestEnginesLoaded()
 {
     if (_modelHolder.IsPrEngineLoaded && _modelHolder.IsIssueEngineLoaded)
     {
         // queued hosted serrvice: task to only download and load models
         Logger.LogInformation("! Checked to see if prediction engines were loaded: {Owner}/{Repo}", _owner, _repo);
         return(Ok("Loaded"));
     }
     // only do this once for per application lifetime for now
     _backgroundTaskQueue.QueueBackgroundWorkItem((ct) => _modelHolder.LoadEnginesAsync());
     return(Ok($"Loading prediction engines."));
 }
Esempio n. 2
0
        public void QueueBackgroundWorkItem(
            Func <CancellationToken, Task> workItem)
        {
            if (workItem == null)
            {
                throw new ArgumentNullException(nameof(workItem));
            }

            if (!_modelHolder.LoadRequested)
            {
                // TODO perhaps restrict to only try once per application lifetime in the future
                _workItems.Enqueue((ct) => _modelHolder.LoadEnginesAsync());
                _signal.Release();
            }

            _workItems.Enqueue(workItem);
            _signal.Release();
        }