This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import threading | |
import datetime | |
import time | |
from random import random | |
class ThreadClass(threading.Thread): | |
def set_id(self, id): | |
self.id=id | |
def dummy_delay(self): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Try to execute the script in two different modes to see the difference | |
# | |
# $ python log.py | tee log | |
# <noting for a long time> | |
# | |
# $ python -u log.py | tee log | |
# my log message 0 | |
# | |
import time |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def cs_create(self, count, sample_nr): | |
name='test' + str(int(time.time())) | |
image=112 | |
flavor=1 | |
log("[%2d][%2d] creating image: " % (sample_nr, count) + pformat( {'name': name, 'image' : image, 'flavor' : flavor } ) ) | |
sm=self.cs.servers | |
server=sm.create(name, image, flavor) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# example code that creates cloud server and try not to hit the cloud API climits | |
cs_count=13 # number of cs to build | |
build_nr=1 | |
delayed_10s=False | |
while build_nr <= cs_count : | |
if 0==build_nr % 11 and not delayed_10s: | |
time.sleep(60+10) | |
NewerOlder