danielfm / pybreaker

Python implementation of the Circuit Breaker pattern.
BSD 3-Clause "New" or "Revised" License
512 stars 74 forks source link

Async support? #7

Open jakubka opened 8 years ago

jakubka commented 8 years ago

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!

danielfm commented 8 years ago

Coroutines are not supported. PRs are welcome though! 😅