I've been using Python for years now, and recently I've discovered asynchronies programming. However, I'm having a rough time trying to implement my ideas...
Let's say I have a regular (synchronized) function g() that returns a value that it computes. Inside this function, I want to call another function, that is asynchronies and runs in a loop - we will call this function f(). The function f() is called inside g(), but the returned value of g() is computed before f() is even called. However, obviously, I want g() to return the value it computed and keep running f() "in the background".
import asyncio
def g(a, b):
    y = a + b
    asyncio.run(f())    # This is blocking!
    return y
async def f():
    for _ in range(3):
        await asyncio.sleep(1)
        print("I'm still alive!")
print(g(3, 5))
# code async code continues here...
# Output:
# I'm still alive!
# I'm still alive!
# I'm still alive!
# 8
# Expected\Wanted:
# 8
# I'm still alive!
# I'm still alive!
# I'm still alive!
Is something like this is even possible? Or am I missing something? Thanks in advance!
 
    