This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author John Belmonte
Recipients John Belmonte, asvetlov, xtreak, yselivanov
Date 2019-06-25.12:36:42
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1561466203.37.0.165083265217.issue37398@roundup.psfhosted.org>
In-reply-to
Content
My use case is for a non-async context manager, and if we take track_entry_and_exit as an example that's non-async as well.

The explicit approach (e.g. separate base class for decorators applied to sync vs. async functions) doesn't seem ideal, because it precludes having a single context manager for both cases.  track_entry_and_exit is an example where a context manager would want to decorate both types of functions.

I'm not sure how big of a problem the iscoroutinefunction() limitation is-- in Trio style we don't pass around coroutines by normal functions.  The `async` qualifier exists to make it clear when a function returns a coroutine, and ContextDecorator already doesn't work for the case of a regular function returning a coroutine.  I think the scope here is to enhance ContextDecorator to work with async functions which are properly qualified with `async`.
History
Date User Action Args
2019-06-25 12:36:43John Belmontesetrecipients: + John Belmonte, asvetlov, yselivanov, xtreak
2019-06-25 12:36:43John Belmontesetmessageid: <1561466203.37.0.165083265217.issue37398@roundup.psfhosted.org>
2019-06-25 12:36:43John Belmontelinkissue37398 messages
2019-06-25 12:36:43John Belmontecreate