libsaria: Remove old threads.py module

Everything in here can easily be duplicated with one line of python
code.  Keeping this file does a good job at increasing complexity.
This commit is contained in:
Bryan Schumaker 2011-05-08 10:57:25 -04:00
parent 217156d322
commit 86f4aca8f3
2 changed files with 2 additions and 43 deletions

View File

@ -5,9 +5,9 @@ from libsaria import sources
from libsaria import web
from libsaria import xm
from libsaria import callbacks
from libsaria import threads
from libsaria import storage
from libsaria.storage import cache
import threading
file_id = libsaria.path.file_id
pref_attr = xm.find_preferred_attribute
@ -74,7 +74,7 @@ def get_album_art(file):
callbacks.get_art(file, id)
def get_artwork(file):
threads.background(get_album_art, file)
threading.Thread(target=get_album_art, args=(file,)).start()
def set_artwork(artist, album, img_path):
cache.copy_in_file(artist, album, "Folder.jpg", img_path)

View File

@ -1,41 +0,0 @@
# Bryan Schumaker (8/19/2010)
import threading
Thread = threading.Thread
Mutex = threading.Lock
mutex_mutex = Mutex()
mutexes = dict()
class BG_Thread(Thread):
def __init__(self, func, *args):
Thread.__init__(self)
self.func = func
self.args = args
def run(self):
self.func(*self.args)
def background(func, *args):
try:
th = BG_Thread(func, *args)
th.start()
return th
except Exception,e:
print e
return None
def get_mutex(lock_name):
global mutexes
global Mutex
global mutex_mutex
mutex_mutex.acquire()
lock = mutexes.get(lock_name, None)
if lock == None:
lock = Mutex()
mutexes[lock_name] = lock
mutex_mutex.release()
return lock