MAZALA2024 commited on
Commit
024bf4a
·
verified ·
1 Parent(s): 555564b

Update rvc_service.py

Browse files
Files changed (1) hide show
  1. rvc_service.py +29 -19
rvc_service.py CHANGED
@@ -177,27 +177,37 @@ class RVCService:
177
  """Start the service"""
178
  if not self.is_running:
179
  self.is_running = True
180
- asyncio.create_task(self.worker_loop())
 
 
 
 
 
 
 
 
 
 
181
  logger.info("RVC Service started")
 
 
 
 
 
182
 
183
- def stop(self):
184
- """Stop the service"""
185
- self.is_running = False
186
- logger.info("RVC Service stopping...")
187
-
188
- async def submit_job(self, audio_data: np.ndarray, model_name: str, priority: int = 1) -> str:
189
- """Submit a new job to the service"""
190
- job_id = f"job_{int(time.time())}_{id(audio_data)}"
191
- job = JobRequest(
192
- id=job_id,
193
- audio_data=audio_data,
194
- model_name=model_name,
195
- priority=priority
196
- )
197
-
198
- if self.job_queue.add_job(job):
199
- return job_id
200
- return None
201
 
202
  # Memory management utilities
203
  def cleanup_gpu_memory():
 
177
  """Start the service"""
178
  if not self.is_running:
179
  self.is_running = True
180
+ # Create a new event loop for the worker
181
+ loop = asyncio.new_event_loop()
182
+ asyncio.set_event_loop(loop)
183
+
184
+ # Start the worker loop in the background
185
+ def run_worker():
186
+ loop.run_until_complete(self.worker_loop())
187
+
188
+ self.worker_thread = threading.Thread(target=run_worker)
189
+ self.worker_thread.daemon = True
190
+ self.worker_thread.start()
191
  logger.info("RVC Service started")
192
+
193
+ def stop(self):
194
+ """Stop the service"""
195
+ self.is_running = False
196
+ logger.info("RVC Service stopping...")
197
 
198
+ async def submit_job(self, audio_data: np.ndarray, model_name: str, priority: int = 1) -> str:
199
+ """Submit a new job to the service"""
200
+ job_id = f"job_{int(time.time())}_{id(audio_data)}"
201
+ job = JobRequest(
202
+ id=job_id,
203
+ audio_data=audio_data,
204
+ model_name=model_name,
205
+ priority=priority
206
+ )
207
+
208
+ if self.job_queue.add_job(job):
209
+ return job_id
210
+ return None
 
 
 
 
 
211
 
212
  # Memory management utilities
213
  def cleanup_gpu_memory():