Best Python code snippet using localstack_python
async_utils.py
Source:async_utils.py
...66 func_wrapped = functools.partial(func, *args, **kwargs)67 return await loop.run_in_executor(thread_pool, copy_context().run, func_wrapped)68def run_coroutine(coroutine, loop=None):69 """Run an async coroutine in a threadsafe way in the main event loop"""70 loop = loop or get_main_event_loop()71 future = asyncio.run_coroutine_threadsafe(coroutine, loop)72 return future.result()73def ensure_event_loop():74 """Ensure that an event loop is defined for the currently running thread"""75 try:76 return asyncio.get_event_loop()77 except Exception:78 loop = asyncio.new_event_loop()79 asyncio.set_event_loop(loop)80 return loop81def get_main_event_loop():82 return get_named_event_loop("_main_")83def get_named_event_loop(name):84 result = EVENT_LOOPS.get(name)85 if result:86 return result87 def async_func_gen(loop, shutdown_event):88 EVENT_LOOPS[name] = loop89 AsyncThread.run_async(async_func_gen)90 time.sleep(1)91 return EVENT_LOOPS[name]92async def receive_from_queue(queue):93 def get():94 # run in a retry loop (instead of blocking forever) to allow for graceful shutdown95 while True:...
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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!