-
Notifications
You must be signed in to change notification settings - Fork 326
Parallel Class
Chris Esposito edited this page Oct 15, 2021
·
9 revisions
Use the parallel class to execute concurrent API calls.
from ebaysdk.finding import Connection as Finding
from ebaysdk.shopping import Connection as Shopping
from ebaysdk.parallel import Parallel
# If you are using Python 3.x, make sure to import ebaysdk.parallel _before_ the other parts of the SDK.
# Otherwise, you will get an exception when you call p.wait()
try:
p = Parallel()
api1 = Shopping(parallel=p)
api1.execute('FindPopularItems', {'QueryKeywords': 'Python'})
api2 = Finding(parallel=p)
api2.execute('findItemsAdvanced', {'keywords': 'shoes'})
api3 = Finding(parallel=p)
api3.execute('findItemsAdvanced', {'keywords': 'shirts'})
api4 = Finding(parallel=p)
api4.execute('findItemsAdvanced', {'keywords': 'pants'})
p.wait()
if p.error():
raise Exception(p.error())
print api1.response.content
print api2.response.dict()
print api3.response.dict()
print api4.response.dict()
except ConnectionError as e:
raise e