Mbonea commited on
Commit
ead0d1e
1 Parent(s): 40cb044

async await

Browse files
Files changed (2) hide show
  1. App/Worker.py +5 -8
  2. App/__init__.py +1 -1
App/Worker.py CHANGED
@@ -85,19 +85,16 @@ def download_assets(links: List[LinkInfo], temp_dir: str):
85
  def render_video(directory: str, output_directory: str):
86
  os.chdir(directory)
87
  os.system(f"npm run build --output {output_directory}")
88
- bot.start()
89
- bot.send_file(-1002069945904, file=output_directory, caption="Your video caption")
90
  print("complete")
91
 
92
 
93
  # @celery.task(name="send")
94
- def cleanup_temp_directory(
95
  temp_dir: str, output_dir: str, chat_id: int = -1002069945904
96
  ):
97
  try:
98
  print("sending...")
99
- bot.start()
100
- bot.send_file(chat_id, file=output_dir, caption="Your video caption")
101
  except Exception as e:
102
  print(e)
103
  finally:
@@ -106,7 +103,7 @@ def cleanup_temp_directory(
106
 
107
 
108
  # @celery.task(name="All")
109
- def celery_task(video_task: EditorRequest):
110
  remotion_app_dir = os.path.join("/srv", "Remotion-app")
111
  project_id = str(uuid.uuid4())
112
  temp_dir = f"/tmp/{project_id}"
@@ -119,8 +116,8 @@ def celery_task(video_task: EditorRequest):
119
  create_json_file(video_task.assets, assets_dir),
120
  download_assets(video_task.links, temp_dir) if video_task.links else None,
121
  render_video(temp_dir, output_dir),
122
- # unsilence.si(temp_dir),
123
- cleanup_temp_directory.si(temp_dir, output_dir),
124
 
125
  # chain(
126
  # copy_remotion_app.si(remotion_app_dir, temp_dir),
 
85
  def render_video(directory: str, output_directory: str):
86
  os.chdir(directory)
87
  os.system(f"npm run build --output {output_directory}")
 
 
88
  print("complete")
89
 
90
 
91
  # @celery.task(name="send")
92
+ async def cleanup_temp_directory(
93
  temp_dir: str, output_dir: str, chat_id: int = -1002069945904
94
  ):
95
  try:
96
  print("sending...")
97
+ await bot.send_file(chat_id, file=output_dir, caption="Your video caption")
 
98
  except Exception as e:
99
  print(e)
100
  finally:
 
103
 
104
 
105
  # @celery.task(name="All")
106
+ async def celery_task(video_task: EditorRequest):
107
  remotion_app_dir = os.path.join("/srv", "Remotion-app")
108
  project_id = str(uuid.uuid4())
109
  temp_dir = f"/tmp/{project_id}"
 
116
  create_json_file(video_task.assets, assets_dir),
117
  download_assets(video_task.links, temp_dir) if video_task.links else None,
118
  render_video(temp_dir, output_dir),
119
+ unsilence(temp_dir),
120
+ await cleanup_temp_directory.si(temp_dir, output_dir),
121
 
122
  # chain(
123
  # copy_remotion_app.si(remotion_app_dir, temp_dir),
App/__init__.py CHANGED
@@ -1,4 +1,4 @@
1
- from telethon.sync import TelegramClient
2
  from telethon.sessions import StringSession
3
  import os
4
 
 
1
+ from telethon import TelegramClient
2
  from telethon.sessions import StringSession
3
  import os
4