Called when a stream is finished to release the lock. Returns: bool: True if stream was successfully released, False if no profile info could be found for cleanup.
(self)
| 246 | return None, None, "All active M3U profiles have reached maximum connection limits", False |
| 247 | |
| 248 | def release_stream(self): |
| 249 | """ |
| 250 | Called when a stream is finished to release the lock. |
| 251 | |
| 252 | Returns: |
| 253 | bool: True if stream was successfully released, False if |
| 254 | no profile info could be found for cleanup. |
| 255 | """ |
| 256 | redis_client = RedisClient.get_client() |
| 257 | |
| 258 | stream_id = self.id |
| 259 | # Get the matched profile for cleanup |
| 260 | profile_id = redis_client.get(f"stream_profile:{stream_id}") |
| 261 | if not profile_id: |
| 262 | logger.debug( |
| 263 | f"Stream {stream_id}: no profile found in " |
| 264 | f"stream_profile:{stream_id}" |
| 265 | ) |
| 266 | return False |
| 267 | |
| 268 | redis_client.delete(f"stream_profile:{stream_id}") # Remove profile association |
| 269 | |
| 270 | profile_id = int(profile_id) |
| 271 | logger.debug( |
| 272 | f"Stream {stream_id}: found profile_id={profile_id}" |
| 273 | ) |
| 274 | |
| 275 | release_profile_slot(profile_id, redis_client) |
| 276 | |
| 277 | return True |
| 278 | |
| 279 | |
| 280 | class ChannelManager(models.Manager): |
no test coverage detected