From f6b715cd650fc6a4c65e32e10fa4e4d88a34c15b Mon Sep 17 00:00:00 2001 From: Michael Pilosov Date: Sun, 19 Mar 2023 17:05:20 -0600 Subject: [PATCH] committing what didn't work --- what_didnt_work.txt | 76 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 what_didnt_work.txt diff --git a/what_didnt_work.txt b/what_didnt_work.txt new file mode 100644 index 0000000..d2de884 --- /dev/null +++ b/what_didnt_work.txt @@ -0,0 +1,76 @@ + +# def announce_server(task=None, loop=None, **outer_kwargs): +# if task is None: +# return lambda f: announce_server(f, loop=loop, **outer_kwargs) + +# @wraps(task) +# def wrapper(*args, **kwargs): +# async def main(*args, **kwargs): +# if loop is not None: +# host_block_thread = loop.run_in_executor(None, task) +# else: +# host_block_thread = asyncio.to_thread(task) # python 3.9+ + +# # Announce the server to the host +# await _announce_server(**outer_kwargs) + +# # Wait for host_block to finish +# await host_block_thread + +# if loop is not None: +# task = loop.create_task(main(*args, **kwargs)) +# else: +# task = asyncio.run(main(*args, **kwargs)) +# return task +# return wrapper + +# def announce_server(task=None, loop=None, **outer_kwargs): +# if task is None: +# return lambda f: announce_server(f, loop=loop, **outer_kwargs) + +# @wraps(task) +# async def wrapper(*args, **kwargs): +# if not asyncio.iscoroutinefunction(task): +# # If the decorated function is not a coroutine, wrap it in a coroutine +# task = asyncio.coroutine(task) +# if loop is not None: +# host_block_thread = loop.run_in_executor(None, task) +# else: +# host_block_thread = asyncio.to_thread(task) + +# # Announce the server to the host +# await _announce_server(**outer_kwargs) + +# # Wait for host_block to finish +# await host_block_thread + +# return wrapper + + +# def announce_server(task=None, loop=None, **outer_kwargs): +# if task is None: +# return lambda f: announce_server(f, loop=loop, **outer_kwargs) + +# if loop is None: +# loop = asyncio.get_event_loop() + +# @wraps(task) +# def wrapper(*args, **kwargs): +# async def main(*args, **kwargs): +# if asyncio.iscoroutinefunction(task): +# # If the task is async, just await it +# host_block_thread = task(*args, **kwargs) +# else: +# host_block_thread = loop.run_in_executor(None, task, *args, **kwargs) + +# # Announce the server to the host +# await _announce_server(**outer_kwargs) + +# # Wait for host_block to finish +# await host_block_thread + +# task = loop.create_task(main(*args, **kwargs)) +# return task + +# return wrapper +