Releases: linuxwhatelse/pyloader
1.0.0
First stable, yiissss!
Breaking changes
Class properties
Both properties, Loader.is_alive
and Loader.is_active
are methods now.
Use Loader.is_alive()
and Loader.is_active()
instead.
import pyloader
loader = pyloader.Loader.get_loader()
loader.configure(...)
loader.is_alive()
loader.is_active()
...
Callbacks
url_resolve_cb
will now receive a DLable
instance (rather than a str
) and is expected to return one again.
import pyloader
def my_url_resolve_cb(item):
item.url = 'http://some.resolved.url'
return item
import pyloader
loader = pyloader.Loader.get_loader()
loader.url_resolve_cb = my_url_resolve_cb
...
Whats new
Apart from bug fixing and general improvements...
Singleton
Rather than creating a Loader
instance yourself, the new and preferred way is as follows:
import pyloader
# Returns a new Loader instance
loader = pyloader.Loader.get_loader()
# Returns the same instance as before
loader = pyloader.Loader.get_loader()
# Returns a new instance
loader2 = pyloader.Loader.get_loader('another_loader')
# Same instance as loader2
loader2 = pyloader.Loader.get_loader('another_loader')
This should make it super easy to integrate into your project as you can now access the same instance from anywhere (yes, it's thread-safe) and queue
, download
, stop
etc. items.
Logging
Even though it's not perfect just yet, some info
logging has been added. More verbose debug
logging will come in the future.
Default log-level is warning
.
Here's an example on how to configure the logger and the log-level:
import pyloader
import logging
logging.basicConfig(format='%(asctime)s %(name)s %(levelname)s [%(threadName)s] %(message)s')
logging.getLogger('pyloader').setLevel(logging.INFO)