MCPcopy Create free account
hub / github.com/AdbAutoPlayer/AdbAutoPlayer / run_task

Function run_task

src-tauri/src-python/adb_auto_player/__main__.py:194–232  ·  view source on GitHub ↗

Wrapper to run task in a separate process.

(
    command: str,
    log_queue: Queue,
    summary_queue: Queue,
    app_config_dir: Path,
    resource_dir: Path,
)

Source from the content-addressed store, hash-verified

192
193
194def run_task(
195 command: str,
196 log_queue: Queue,
197 summary_queue: Queue,
198 app_config_dir: Path,
199 resource_dir: Path,
200) -> None:
201 """Wrapper to run task in a separate process."""
202 queue_handler = QueueHandler(log_queue)
203 logger = logging.getLogger()
204 logger.setLevel(logging.DEBUG)
205 logger.addHandler(queue_handler)
206
207 def summary_callback(msg: str | None):
208 # We are catching all exceptions here regardless
209 # because we never want the summary to actually stop the process via error
210 if summary_queue.full():
211 try:
212 summary_queue.get_nowait()
213 except (queue.Empty, Exception):
214 pass
215 try:
216 summary_queue.put_nowait(msg)
217 except (queue.Full, Exception):
218 # queue.Full should really never happen here but leaving as is
219 pass
220
221 SummaryGenerator.set_callback(summary_callback)
222 SettingsLoader.set_app_config_dir(app_config_dir)
223 SettingsLoader.set_resource_dir(resource_dir)
224
225 try:
226 e = Execute.find_command_and_execute(command, get_game_tasks())
227 if isinstance(e, BaseException):
228 logging.error(e)
229 sys.exit(1)
230 except Exception as exc:
231 logging.error(exc)
232 sys.exit(1)
233
234
235class StartTaskBody(ProfileContext):

Callers

nothing calls this directly

Calls 5

get_game_tasksFunction · 0.90
set_callbackMethod · 0.80
set_app_config_dirMethod · 0.80
set_resource_dirMethod · 0.80

Tested by

no test coverage detected