fix: enable multi tenant comfy workspace

This commit is contained in:
boos
2026-05-22 00:44:57 +08:00
parent 5ef3f8aea8
commit 7c6364a160
3 changed files with 106 additions and 35 deletions
+10 -2
View File
@@ -189,7 +189,11 @@ impl ComfyUIPool {
/// handle. Idempotent.
pub async fn get_or_start(&self, user_id: i64) -> PoolResult<PoolEntry> {
// Fast path: already ready.
if let Some(entry) = self.containers.read().await.get(&user_id).cloned() {
let existing = {
let map = self.containers.read().await;
map.get(&user_id).cloned()
};
if let Some(entry) = existing {
if entry.state == ContainerState::Ready {
self.touch_inner(user_id).await;
return Ok(entry);
@@ -206,7 +210,11 @@ impl ComfyUIPool {
let _g = lock.lock().await;
// Re-check after acquiring the lock; another task may have done the work.
if let Some(entry) = self.containers.read().await.get(&user_id).cloned() {
let existing = {
let map = self.containers.read().await;
map.get(&user_id).cloned()
};
if let Some(entry) = existing {
if entry.state == ContainerState::Ready {
self.touch_inner(user_id).await;
return Ok(entry);