81 lines
		
	
	
		
			1.5 KiB
		
	
	
	
		
			Python
		
	
	
	
	
	
			
		
		
	
	
			81 lines
		
	
	
		
			1.5 KiB
		
	
	
	
		
			Python
		
	
	
	
	
	
import asyncio
 | 
						|
import time
 | 
						|
 | 
						|
from limiter import BatchLimiter
 | 
						|
 | 
						|
 | 
						|
async def test1():
 | 
						|
    limiter = BatchLimiter()
 | 
						|
    cnt = 0
 | 
						|
    for i in range(100):
 | 
						|
        await limiter.acquire_ozon('denco')
 | 
						|
        cnt += 1
 | 
						|
        print('ozon denco-1', cnt)
 | 
						|
 | 
						|
 | 
						|
async def test2():
 | 
						|
    limiter = BatchLimiter()
 | 
						|
    cnt = 0
 | 
						|
    for i in range(100):
 | 
						|
        await limiter.acquire_ozon('denco')
 | 
						|
        cnt += 1
 | 
						|
        print('ozon denco-2', cnt)
 | 
						|
 | 
						|
 | 
						|
async def test3():
 | 
						|
    limiter = BatchLimiter()
 | 
						|
    cnt = 0
 | 
						|
    for i in range(100):
 | 
						|
        await limiter.acquire_wildberries('denco')
 | 
						|
        cnt += 1
 | 
						|
        print('wb denco-1', cnt)
 | 
						|
 | 
						|
 | 
						|
async def test4():
 | 
						|
    limiter = BatchLimiter()
 | 
						|
    cnt = 0
 | 
						|
    for i in range(100):
 | 
						|
        await limiter.acquire_wildberries('denco')
 | 
						|
        cnt += 1
 | 
						|
        print('wb denco-2', cnt)
 | 
						|
 | 
						|
 | 
						|
async def test5():
 | 
						|
    limiter = BatchLimiter()
 | 
						|
    cnt = 0
 | 
						|
    for i in range(100):
 | 
						|
        await limiter.acquire_wildberries('denco')
 | 
						|
        cnt += 1
 | 
						|
        print('wb denco-2', cnt)
 | 
						|
 | 
						|
 | 
						|
async def test6():
 | 
						|
    limiter = BatchLimiter()
 | 
						|
    cnt = 0
 | 
						|
    for i in range(100):
 | 
						|
        await limiter.acquire_ozon('bolgov')
 | 
						|
        cnt += 1
 | 
						|
        print('wb bolgov-1', cnt)
 | 
						|
 | 
						|
 | 
						|
async def test():
 | 
						|
    start = time.time()
 | 
						|
    await asyncio.gather(*[
 | 
						|
        test1(),
 | 
						|
        test2(),
 | 
						|
        test3(),
 | 
						|
        test4(),
 | 
						|
        # test5(),
 | 
						|
        # test6(),
 | 
						|
    ])
 | 
						|
    print(time.time() - start)
 | 
						|
 | 
						|
 | 
						|
def main():
 | 
						|
    loop = asyncio.get_event_loop()
 | 
						|
    loop.run_until_complete(test())
 | 
						|
 | 
						|
 | 
						|
if __name__ == '__main__':
 | 
						|
    main()
 |