Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upAsync context manager #535
Comments
|
How would that work, keeping in mind that we support all the way back to 2.6? |
|
Well, I didn't think about it. Sorry. |
|
@brian-brazil, what do you think about Python version check inside decorator to exclude support for non-async syntax. Seems like it's not gonna affect backwards support. And will come really handy |
|
I'm not sure how that'd work given that it's a syntax thing, and thus 2.6 would choke on it. |
|
Yup, actually i was thinking about depending on version import of async compatible syntax. But it looks too complex and such case may be implemented easier with context manager as well. c = Counter("errors_count")
async def foo_async():
with c.count_exceptions():
await sleep(1)
raise Exception()actually if someone really need the decorator then he can implement it by himself with a few lines of code |
Usecase:
Quick search in project did nothing to me.
It would be cool if counter (and other objects) would handle this right out of the box, especially if we're talking about metrics for web world.