Closed LeonPoon closed 3 years ago
I actually only just realised the same thing is also being requested via #21 .
Thanks for working on this! My low-level python is a bit rusty, but I wonder, would it be possible to do something async like [1]? It might be a bit more in line with how other APIs generally behave for such tasks.
Python3 asyncio is relatively new to me so I took a bit of time today to do research.
Seems to me if we are to support it properly, we need to do this:
Most of these are simple on its own but will take some time to implement the complete list. Going to take longer than the original work (took me a day for that)!
I will update when I have a go at it, meanwhile please send ideas if any - esp for managing the async notification part, if there are already existing solution. If there aren't then maybe it justify a new lib. Seems fun.
Perhaps some other people can also express their opinion, from my part I was just wondering whether one could expose the api in a form like (abstractly written):
job = start_scan_job(progressCallback = function(cur,tot), finishCallback=(result))
job.cancel()
Whether that is specifically with the python3 async API is another question, though it seemed the closest at a first glance.
Again, this is just my opinion.
Progress callbacks have been added in [1] and [2].
[1] https://github.com/python-pillow/Sane/commit/921151fb1be722db9731d7eaad16e334e0e685e4 [2] https://github.com/python-pillow/Sane/commit/5ef27fccd11319c26dd0ea04efaf5415aa6a948c
In order to avoid touching lots of lines so as to keep the patch clean, things are copied out from the SaneSnapperObject struct to local variables before manipulation by existing code and copied back after.
Appreciate review. Thank you.