Skip to content

Instantly share code, notes, and snippets.

@krotkiewicz
Last active December 15, 2015 02:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save krotkiewicz/f741b05265ccc1927123 to your computer and use it in GitHub Desktop.
Save krotkiewicz/f741b05265ccc1927123 to your computer and use it in GitHub Desktop.
api = get_carrier('fedex', self.config)
#load Client and wsdl file:
# >>> api.client
# *** AttributeError: 'Fedex' object has no attribute 'client'
response = api.get_rates('78701', '78701', 2, 'GROUND')
# >>> api.client
# <suds.client.Client object at 0x10b6783d0>
# api.client is cloned each time when api.get_rates is called so it is thread safe
# and wsdl file is loaded only once.
if type_ == 'sync':
start = time.time()
for x in range(HOW_MANY):
response = api.get_rates('78701', '78701', 2, 'GROUND')
end = time.time()
elif type_ == 'single':
start = time.time()
response = api.get_rates('78701', '78701', 2, 'GROUND')
end = time.time()
else:
threads = []
start = time.time()
for x in range(HOW_MANY):
t = Thread(api)
t.start()
threads.append(t)
for t in threads:
t.join()
end = time.time()
a_time = end - start
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment