How to use initiate_cleanup method in Slash

Best Python code snippet using slash

worker.py

Source:worker.py Github

copy

Full Screen

...117 self.write_to_error_file(str(err))118 raise119 else:120 context.session.mark_complete()121 context.session.initiate_cleanup()122 self._stop_keepalive_thread()123 self.client.disconnect(self.client_id)124 finally:125 context.session.initiate_cleanup()...

Full Screen

Full Screen

cleanup.py

Source:cleanup.py Github

copy

Full Screen

2import logging3import os4import time5from .constants import REWINDER_RECORDINGS_DIR, logger6def initiate_cleanup(retain_recordings_till_minutes: int, run_cleanup_every_x_min: int):7 logger.info(f"initiating cleanup")8 logger.info(f"retaining recording till {retain_recordings_till_minutes} min")9 logger.info(f"running cleanup evey {run_cleanup_every_x_min} min")10 current_time = int(time.time())11 retain_recordings_till = current_time - (retain_recordings_till_minutes * 60)12 list_of_files = glob.glob(os.path.join(REWINDER_RECORDINGS_DIR, "*.wav"))13 start_times = list(14 sorted(int(el.split("/")[-1].replace(".wav", "")) for el in list_of_files)15 )16 files_to_delete = [17 os.path.join(REWINDER_RECORDINGS_DIR, f"{ts}.wav")18 for ts in start_times19 if ts < retain_recordings_till20 ]21 logger.info(f"deleting files: {files_to_delete}")22 [os.remove(f) for f in files_to_delete]23 time.sleep(run_cleanup_every_x_min * 60)24def schedule_cleanup(25 retain_recordings_till_minutes: int = 60, run_cleanup_every_x_min: int = 3026):27 while True:...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Slash automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful