John Wong
2015-09-16 00:46:31 UTC
Hi
Here is the code:
def create_vm(.....):
# returns vm object
def modify_vm(.....):
return new vm object
def get_vm_status(.....):
return status
# Constraints:
# I cannot modify vm until vm is finished,
# I also cannot modify VM while the VM is being updated.
# Obviously it looks ugly and wrong to include the while
# in my functio. Those are user APIs.
# Straight-forward option
create_vm(...)
status = get_vm_status(...)
while status != "ready":
time.sleep(10)
status = get_vm_status(...)
modify_vm(....)
while status != "ready":
time.sleep(10)
status = get_vm_status(...)
print("done!")
I was thinking about context manager. But I feel like that's not the
right choice. If you can guess cloning a vm in my program will require
several more function calls. What's your recommendation to accomplish
this?
Thank you.
John
_______________________________________________
Tutor maillist - ***@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor
Here is the code:
def create_vm(.....):
# returns vm object
def modify_vm(.....):
return new vm object
def get_vm_status(.....):
return status
# Constraints:
# I cannot modify vm until vm is finished,
# I also cannot modify VM while the VM is being updated.
# Obviously it looks ugly and wrong to include the while
# in my functio. Those are user APIs.
# Straight-forward option
create_vm(...)
status = get_vm_status(...)
while status != "ready":
time.sleep(10)
status = get_vm_status(...)
modify_vm(....)
while status != "ready":
time.sleep(10)
status = get_vm_status(...)
print("done!")
I was thinking about context manager. But I feel like that's not the
right choice. If you can guess cloning a vm in my program will require
several more function calls. What's your recommendation to accomplish
this?
Thank you.
John
_______________________________________________
Tutor maillist - ***@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor