Spaces:
Running
Running
Monteeq CI commited on
Commit ·
5835322
1
Parent(s): d8cd523
🚀 Deploy from GitHub @ 213a59492267ccd422e0a1819b42e1f47f811705
Browse filesTriggered by: Smasduq
Message: fix: adjust worker pool configuration for Windows compatibility
Updated the worker pool settings in worker.py to use a solo pool and set concurrency to 1 on Windows platforms, addressing issues with prefork/spawn pools that caused crashes. This change ensures better stability for Windows users while maintaining the original settings for other platforms.
- app/api/v1/endpoints/videos.py +20 -3
- app/worker.py +3 -1
app/api/v1/endpoints/videos.py
CHANGED
|
@@ -19,7 +19,8 @@ from app.core import config
|
|
| 19 |
from app.utils.push import notify_user_push
|
| 20 |
from app.core.storage import storage
|
| 21 |
from app.core.config import FLASH_QUOTA_LIMIT, HOME_QUOTA_LIMIT
|
| 22 |
-
from app.models.models import Video, User
|
|
|
|
| 23 |
from app.services.email_service import send_challenge_exit_email
|
| 24 |
from app.core.redis import redis_client
|
| 25 |
|
|
@@ -486,13 +487,29 @@ def delete_video(
|
|
| 486 |
delete_video_files(video)
|
| 487 |
|
| 488 |
# Handle challenge entry counts and notifications
|
| 489 |
-
for entry in video.challenge_entries:
|
| 490 |
if entry.challenge:
|
| 491 |
entry.challenge.entry_count = max(0, entry.challenge.entry_count - 1)
|
| 492 |
# Notify the user
|
| 493 |
if entry.user and entry.user.email:
|
| 494 |
-
|
|
|
|
|
|
|
|
|
|
| 495 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 496 |
# Delete from DB
|
| 497 |
db.delete(video)
|
| 498 |
db.commit()
|
|
|
|
| 19 |
from app.utils.push import notify_user_push
|
| 20 |
from app.core.storage import storage
|
| 21 |
from app.core.config import FLASH_QUOTA_LIMIT, HOME_QUOTA_LIMIT
|
| 22 |
+
from app.models.models import Video, User, View, WatchLater, Repost, VideoInteraction
|
| 23 |
+
from app.models.library import WatchHistory, LibraryWatchLater, LikedVideo
|
| 24 |
from app.services.email_service import send_challenge_exit_email
|
| 25 |
from app.core.redis import redis_client
|
| 26 |
|
|
|
|
| 487 |
delete_video_files(video)
|
| 488 |
|
| 489 |
# Handle challenge entry counts and notifications
|
| 490 |
+
for entry in list(video.challenge_entries):
|
| 491 |
if entry.challenge:
|
| 492 |
entry.challenge.entry_count = max(0, entry.challenge.entry_count - 1)
|
| 493 |
# Notify the user
|
| 494 |
if entry.user and entry.user.email:
|
| 495 |
+
try:
|
| 496 |
+
send_challenge_exit_email(entry.user.email, entry.user.username, entry.challenge.title)
|
| 497 |
+
except Exception as e:
|
| 498 |
+
logger.warning(f"Challenge exit email failed for video {video.id}: {e}")
|
| 499 |
|
| 500 |
+
# Clear FK rows that lack ON DELETE CASCADE (blocks delete on watched/saved videos)
|
| 501 |
+
vid = video.id
|
| 502 |
+
db.query(User).filter(User.pinned_video_id == vid).update(
|
| 503 |
+
{User.pinned_video_id: None}, synchronize_session=False
|
| 504 |
+
)
|
| 505 |
+
db.query(View).filter(View.video_id == vid).delete(synchronize_session=False)
|
| 506 |
+
db.query(WatchLater).filter(WatchLater.video_id == vid).delete(synchronize_session=False)
|
| 507 |
+
db.query(Repost).filter(Repost.video_id == vid).delete(synchronize_session=False)
|
| 508 |
+
db.query(VideoInteraction).filter(VideoInteraction.video_id == vid).delete(synchronize_session=False)
|
| 509 |
+
db.query(WatchHistory).filter(WatchHistory.video_id == vid).delete(synchronize_session=False)
|
| 510 |
+
db.query(LibraryWatchLater).filter(LibraryWatchLater.video_id == vid).delete(synchronize_session=False)
|
| 511 |
+
db.query(LikedVideo).filter(LikedVideo.video_id == vid).delete(synchronize_session=False)
|
| 512 |
+
|
| 513 |
# Delete from DB
|
| 514 |
db.delete(video)
|
| 515 |
db.commit()
|
app/worker.py
CHANGED
|
@@ -30,7 +30,9 @@ celery_app.conf.update(
|
|
| 30 |
task_time_limit=3600,
|
| 31 |
broker_pool_limit=20,
|
| 32 |
redis_max_connections=20,
|
| 33 |
-
|
|
|
|
|
|
|
| 34 |
broker_transport_options={
|
| 35 |
'visibility_timeout': 3600,
|
| 36 |
'max_connections': 20
|
|
|
|
| 30 |
task_time_limit=3600,
|
| 31 |
broker_pool_limit=20,
|
| 32 |
redis_max_connections=20,
|
| 33 |
+
# prefork/spawn pools crash on Windows (WinError 6 / Access denied)
|
| 34 |
+
worker_pool="solo" if sys.platform == "win32" else "prefork",
|
| 35 |
+
worker_concurrency=1 if sys.platform == "win32" else 4,
|
| 36 |
broker_transport_options={
|
| 37 |
'visibility_timeout': 3600,
|
| 38 |
'max_connections': 20
|