Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pass along args in launch_task #18

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 29 additions & 22 deletions source/vectoros.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ async def launch_repl():

vos_state.task_dict['$repl']=asyncio.create_task(aiorepl.task())

async def launch(task_tag):
async def launch(task_tag, *args, **kwargs):
"""
Asynchronous function to launch a program by its tag.

Expand All @@ -90,36 +90,43 @@ async def launch(task_tag):

Returns:
Task: The created task.
"""
if vos_state.gc_suspend==False:
"""

if vos_state.gc_suspend == False:
gc.collect()
vos_debug.debug_print(vos_debug.DEBUG_LEVEL_INFO,f"launching {task_tag}")
mod=__import__(launch_list[task_tag])
vos_debug.debug_print(vos_debug.DEBUG_LEVEL_INFO, f"launching {task_tag}")
mod = __import__(launch_list[task_tag])
try:
fn=getattr(mod,'vos_main')
fn = getattr(mod,'vos_main')
except Exception:
vos_debug.debug_print(vos_debug.DEBUG_LEVEL_WARNING,f"launch could not find vos_main for {task_tag}. Trying main()")
fn=getattr(mod,'main')
vos_debug.debug_print(
vos_debug.DEBUG_LEVEL_WARNING,
f"launch could not find vos_main for {task_tag}. Trying main()",
)
fn = getattr(mod,'main')
try:
await fn()
except TypeError:
await fn(*args, **kwargs)
except TypeError as e:
print(f"Exception lauching task {task_tag}:", e)
pass



def launch_task(task_tag):
"""
Function to create async task to launch.
def launch_task(task_tag, *args, **kwargs):
"""
Function to create async task to launch.

Args:
task_tag (str): The tag of the program to launch.

Returns:
Task: The created task.
"""

vos_state.task_dict[task_tag] = asyncio.create_task(
launch(task_tag, *args, **kwargs))


Args:
task_tag (str): The tag of the program to launch.

Returns:
Task: The created task.
"""
vos_state.task_dict[task_tag]=asyncio.create_task(launch(task_tag))


async def launch_vecslot(slot):
from vectorscope import Vectorscope
_screen.clear()
Expand Down