pybreaker icon indicating copy to clipboard operation
pybreaker copied to clipboard

Async support?

Open jakubka opened this issue 9 years ago • 1 comments

Hey, pybreaker doesn't behave as expected with async code on the asyncio event loop. Is it because it isn't supported or am I doing something wrong?

Here's my code:

data_services_breaker = pybreaker.CircuitBreaker(fail_max=2, reset_timeout=60)

@data_services_breaker
async def get_all_bookings():
    async with aiohttp.ClientSession() as session:
        async with session.get('https://api.githubXXXX.com/events') as resp:
            return await resp.text()

CircuitBreakerError is never thrown...

Thanks!

jakubka avatar Aug 17 '16 10:08 jakubka

Coroutines are not supported. PRs are welcome though! 😅

danielfm avatar Aug 17 '16 13:08 danielfm