Conversation
3041a89 to
43cd5a7
Compare
43cd5a7 to
003e45d
Compare
| return asyncio.iscoroutinefunction(obj) or ( | ||
| callable(obj) and asyncio.iscoroutinefunction(obj.__call__) | ||
| return inspect.iscoroutinefunction(obj) or ( | ||
| callable(obj) and inspect.iscoroutinefunction(getattr(obj, "__call__", None)) |
There was a problem hiding this comment.
I'm sorry to ask a dummy question, is the getattr necessary here?
There was a problem hiding this comment.
prob. not, unsure what i was thinking there.
There was a problem hiding this comment.
Sorry for the back and forth, i've been writing loads of tests to dig here see.
But the gist of it; Yes, getattr is needed. inspect.iscoroutinefunction(obj) only works for actual async function objects. Instances with async call return False there, so you must look at obj.call. Using getattr(obj, "call", None) avoids an AttributeError and cleanly checks the bound method. Without it you’d misclassify async callable instances or need a try/except.
EDIT;
Make sure to check look at these test cases; https://github.com/janbjorge/pgqueuer/pull/473/files#diff-998ed263122511bfcb910e08f8830fd62a83287a5b2aec5a40e351f5ba5d47adR536
There was a problem hiding this comment.
thanks for your reply, I didn't aware of that
There was a problem hiding this comment.
thanks for asking @trim21 it lead me down an crazy rabithole that i enjoyed!
The below PR / issues needs to be closed before we can add support for py314.