forked from boos/BoosAPI
fix: enable multi tenant comfy workspace
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user