* fixed: crashes when adding a job to Asynchronizer and starting it when it already started.
This commit is contained in:
parent
ace8109ad7
commit
7e203ee5a2
|
@ -1,3 +1,6 @@
|
||||||
|
0.2b9
|
||||||
|
* fixed: crashes when adding a job to Asynchronizer and starting it when it already started.
|
||||||
|
|
||||||
0.2b8
|
0.2b8
|
||||||
* Asynchronizer.async_call now accepts None as callback.
|
* Asynchronizer.async_call now accepts None as callback.
|
||||||
* moved all the tag related functions to a separate Taggable class.
|
* moved all the tag related functions to a separate Taggable class.
|
||||||
|
|
17
pylast.py
17
pylast.py
|
@ -22,7 +22,7 @@
|
||||||
# documentation at http://code.google.com/p/pylast/wiki/Documentation
|
# documentation at http://code.google.com/p/pylast/wiki/Documentation
|
||||||
|
|
||||||
LIB_NAME = 'pyLast'
|
LIB_NAME = 'pyLast'
|
||||||
LIB_VERSION = '0.2b8'
|
LIB_VERSION = '0.2b9'
|
||||||
|
|
||||||
API_SERVER = 'ws.audioscrobbler.com'
|
API_SERVER = 'ws.audioscrobbler.com'
|
||||||
API_SUBDIR = '/2.0/'
|
API_SUBDIR = '/2.0/'
|
||||||
|
@ -123,9 +123,19 @@ class Asynchronizer(threading.Thread):
|
||||||
self._calls = {} #calls is structured like this: {call_pointer: (arg1, arg2, ...)}
|
self._calls = {} #calls is structured like this: {call_pointer: (arg1, arg2, ...)}
|
||||||
self._callbacks = {} #callbacks is structred like this: {call_pointer: callback_pointer}
|
self._callbacks = {} #callbacks is structred like this: {call_pointer: callback_pointer}
|
||||||
|
|
||||||
|
self.is_running = False
|
||||||
|
|
||||||
|
def isRunning(self):
|
||||||
|
"""Returns if the thread is already running, for usage instead of isAlive which doesn't believe in thread restarting."""
|
||||||
|
|
||||||
|
return self.is_running
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
"""Avoid running this function. Use start() to begin the thread's work."""
|
"""Avoid running this function. Use start() to begin the thread's work."""
|
||||||
|
|
||||||
|
self.is_running = True
|
||||||
|
|
||||||
|
while len(self._calls):
|
||||||
for call in self._calls.keys():
|
for call in self._calls.keys():
|
||||||
|
|
||||||
output = call(*(self._calls[call]))
|
output = call(*(self._calls[call]))
|
||||||
|
@ -137,6 +147,8 @@ class Asynchronizer(threading.Thread):
|
||||||
del self._calls[call]
|
del self._calls[call]
|
||||||
del self._callbacks[call]
|
del self._callbacks[call]
|
||||||
|
|
||||||
|
self.is_running = False
|
||||||
|
|
||||||
def async_call(self, callback, call, *call_args):
|
def async_call(self, callback, call, *call_args):
|
||||||
"""This is the function for setting up an asynchronous operation.
|
"""This is the function for setting up an asynchronous operation.
|
||||||
* callback: the function to callback afterwards, accepting two argument, one being the sender and the other is the return of the target call.
|
* callback: the function to callback afterwards, accepting two argument, one being the sender and the other is the return of the target call.
|
||||||
|
@ -150,6 +162,9 @@ class Asynchronizer(threading.Thread):
|
||||||
def start(self):
|
def start(self):
|
||||||
"""Since that Python thread objects can only be started once. This is my little work-around."""
|
"""Since that Python thread objects can only be started once. This is my little work-around."""
|
||||||
|
|
||||||
|
if self.isRunning():
|
||||||
|
return
|
||||||
|
|
||||||
threading.Thread.__init__(self)
|
threading.Thread.__init__(self)
|
||||||
super(Asynchronizer, self).start()
|
super(Asynchronizer, self).start()
|
||||||
|
|
||||||
|
|
2
setup.py
2
setup.py
|
@ -1,7 +1,7 @@
|
||||||
from distutils.core import setup
|
from distutils.core import setup
|
||||||
|
|
||||||
setup(name='pylast',
|
setup(name='pylast',
|
||||||
version='0.2b8',
|
version='0.2b9',
|
||||||
author='Amr Hassan',
|
author='Amr Hassan',
|
||||||
long_description = 'Python bindings for the Last.fm API 2.0',
|
long_description = 'Python bindings for the Last.fm API 2.0',
|
||||||
author_email='amr.hassan@gmail.com',
|
author_email='amr.hassan@gmail.com',
|
||||||
|
|
Loading…
Reference in a new issue