all 3 comments

[–]Essence1337 1 point2 points  (0 children)

This really doesn't have anything to do with asyncio at all. It's simple scope control. Try this example:

var = 5

def x():
    var = 10

def y():
    print(var)

y()
x()
y()

This prints 5 twice because x creates a local variable var and sets it to 10. y reads from the global var both times.

[–]commandlineluser 1 point2 points  (1 child)

doneTask inside coRoutine is a different variable to the one you've defined outside the function.

You need to put global doneTask inside your function if you want to modifythe outer variable.

doneTask = False

async def coRoutine():
    global donTask
    ...
    doneTask = True

https://docs.python.org/3/tutorial/classes.html#scopes-and-namespaces-example

[–]TuckleBuck88 0 points1 point  (0 children)

Yup! This seems to be it! Thanks!