-
-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
loader.py
: use urllib3
, support custom timeout
#8602
Comments
I am working on a refactor of loader.py in the background, so listening with interest. Do you want to share the changes you tried? |
Sure! To prove to myself that adding pooling would make the difference for me I created a MyAsyncImage/myasyncimage.py so that I could make it load my hacky MyLoader/myloader.py rather than the Kivy code one. It was basically copy/paste, apart from the changes indicated below. This was just a test, I'm sure it needs more thought than this.
|
And how it behave when you change default network backend to "requests"? Its single line in config file Can someone benchmark it? |
The There is no session mechanism for the "requests" implementation, so that shouldn't make a difference? On my app I make several requests to my API on start up, I had a huge efficiency boost after I implemented sessions for that. Currently, I create a session in my App class, save it as a class attribute and then pass the session object as an argument to e.g. my API request module. It works fine but seems a bit hacky to do it this way. There might be scope to handle this better? |
it uses Try
it should work from kivy 2.2.0 kivy/kivy/network/urlrequest.py Line 781 in 340ea0d
|
Is your feature request related to a problem? Please describe.
My app returns a search result in
RecycleView
with each result containing a small thumbnail logo of ~15kb. The short 60 second loader cache timeout combined with the inefficient image loading means that by the time the last image is loaded the first images are already flushed from the cache so restart loading again.I "hacked" loader.py on my setup: I set timeout to 180, replaced
urllib.request
withurllib3
and instantiated a pool manager. The image load is massively more efficient now. (My images are all hosted on one server).Describe the solution you'd like
Replace the old
urllib
:urllib3
has a pool manager, which massively improves efficiency and speed when reusing the same connection (e.g. images hosted on the same server).The timeout for keeping images in cache is currently hard coded to 60 seconds. This should be configurable depending on use-case, same as
num_workers
andmax_upload_per_frame
are now. e.g.Loader.timeout = 180
The text was updated successfully, but these errors were encountered: