Support direct .__await__
See original GitHub issueHey there, seems like a nice library. It’s just a small suggestion and opinion, but you can add __await__
for the queries, instead of kind of an annoying .run
every time
class Q:
async def _actual_call(self) -> T:
# .... do_some_work .... '
return
def __await__(self) -> Generator[None, None, T]:
return self._actual_call().__await__()
q = Q()
await q
Suggestion related to picollo/query/base::Query
Issue Analytics
- State:
- Created 3 years ago
- Comments:10 (9 by maintainers)
Top Results From Across the Web
await - JavaScript - MDN Web Docs
The await operator is used to wait for a Promise and get its fulfillment value. It can only be used inside an async...
Read more >Async/await - The Modern JavaScript Tutorial
The keyword await makes JavaScript wait until that promise settles and returns its result. Here's an example with a promise that resolves in...
Read more >Javascript: async and await, a Complete Guide | by Harsh Patel
Start by declaring the function as async . This declaration allows await to be used from within. The asynchronous routine ( fetch in...
Read more >Async Await performance - Direct method call vs Task wrapper ...
A small program that I have created to understand the working of Async Await and calling the async method in a for loop,...
Read more >JavaScript async and await - in plain English, please
The await keyword is for making the JavaScript function execution wait until a promise is settled(either resolved or rejected) and value/error ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@sinisaos I’ll keep
.run()
as the default way of doing things in the docs. It makes it slightly more future proof, asrun()
can accept arguments - currently it’s just whether or not to run the query in a connection pool, which is mostly used for testing purposes, but there may be other arguments which need to be added in the future. The__await__
magic method can be there as a convenience, for people who prefer the more compact syntax. I won’t add the__call__
magic method for now - it’s just too weird.@sinisaos Good suggestion - I’ll take a look.