简体   繁体   中英

Where does a Python `schedule` scheduled task's return value go?

I have a scheduled task that runs using the schedule library. Where does the return value of my task go? Does returning True have a different effect than returning False ?

Example:

def foo():
    return False

schedule.every().day.do(foo)
while True:
    schedule.run_pending()
    time.sleep(1)

It doesn't "go" anywhere. Every object has a reference count, and a call like

a = foo()

would simply increment the reference count of whatever object False refers to, to reflect that a is now also an reference to the same object.

In the absence of any such assignment, like with

foo()

the reference count simply is not incremented. If the only other reference to the value was a name local to foo , then the object would be subject to garbage collection.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM