MCPcopy Index your code
hub / github.com/easydiffusion/easydiffusion / start

Method start

ui/media/js/engine.js:1084–1150  ·  view source on GitHub ↗
(progressCallback)

Source from the content-addressed store, hash-verified

1082 return Task.enqueueNew(this, FilterTask, progressCallback)
1083 }
1084 *start(progressCallback) {
1085 if (typeof progressCallback !== "undefined" && typeof progressCallback !== "function") {
1086 throw new Error("progressCallback is not a function. progressCallback type: " + typeof progressCallback)
1087 }
1088 if (this.isStopped) {
1089 return
1090 }
1091
1092 this._setStatus(TaskStatus.pending)
1093 progressCallback?.call(this, { reqBody: this._reqBody })
1094 Object.freeze(this._reqBody)
1095
1096 // Post task request to backend
1097 let renderRes = undefined
1098 try {
1099 renderRes = yield this.post()
1100 yield progressCallback?.call(this, { renderResponse: renderRes })
1101 } catch (e) {
1102 yield progressCallback?.call(this, { detail: e.message })
1103 throw e
1104 }
1105
1106 try {
1107 // Wait for task to start on server.
1108 yield this.waitUntil({
1109 callback: function () {
1110 return progressCallback?.call(this, {})
1111 },
1112 status: TaskStatus.processing,
1113 })
1114 } catch (e) {
1115 this.abort(err)
1116 throw e
1117 }
1118
1119 // Task started!
1120 // Open the reader.
1121 const reader = this.reader
1122 const task = this
1123 reader.onError = function (response) {
1124 if (progressCallback) {
1125 task.abort(new Error(response.statusText))
1126 return progressCallback.call(task, { response, reader })
1127 }
1128 return Task.prototype.onError.call(task, response)
1129 }
1130 yield progressCallback?.call(this, { reader })
1131
1132 //Start streaming the results.
1133 const streamGenerator = reader.open()
1134 let value = undefined
1135 let done = undefined
1136 yield progressCallback?.call(this, { stream: streamGenerator })
1137 do {
1138 ; ({ value, done } = yield streamGenerator.next())
1139 if (typeof value !== "object") {
1140 continue
1141 }

Callers

nothing calls this directly

Calls 6

postMethod · 0.95
_setStatusMethod · 0.80
waitUntilMethod · 0.80
abortMethod · 0.80
openMethod · 0.80
startMethod · 0.45

Tested by

no test coverage detected