-
-
Save jeiting/481884 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def remove(self, uid = None): | |
"""Remove an element with UID = uid from the queue.""" | |
if (uid is None): | |
raise qManagerException("remove: Provide a UID for removal.") | |
if (not self.lockFlag): | |
the_elem = None | |
for elem in self: | |
Log.debug("found UID %s" % elem['UID']) | |
if (elem['UID'] == uid): | |
the_elem = elem | |
break | |
if the_elem is not None: | |
try: | |
self.qLock.acquire() | |
self.remove(elem) | |
self.qLock.release() | |
self._publishQueue() | |
return "SUCCESS" | |
except Exception, msg: | |
Log.error("qManager: remove: Exception caught: %s" % | |
msg) | |
raise | |
else: | |
rString = ("remove: UID %s is not in the queue." % str(uid)) | |
Log.error('qManager: %s' % rString) | |
raise qManagerException(rString) | |
else: | |
Log.error('qManager: remove: Queue is locked.') | |
raise qManagerException("Queue is locked.") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
def remove(self, uid = None):
"""Remove an element with UID = uid from the queue."""
if (uid is None):
raise qManagerException("remove: Provide a UID for removal.")
if (not self.lockFlag):
the_elem = None
for elem in self:
Log.debug("found UID %s" % elem['UID'])
if (elem['UID'] == uid):
the_elem = elem
break
if the_elem is not None:
try:
self.qLock.acquire()
self.remove(elem)
self.qLock.release()
self._publishQueue()
return "SUCCESS"
except Exception, msg:
Log.error("qManager: remove: Exception caught: %s" %
msg)
raise
else:
rString = ("remove: UID %s is not in the queue." % str(uid))
Log.error('qManager: %s' % rString)
raise qManagerException(rString)
else:
Log.error('qManager: remove: Queue is locked.')
raise qManagerException("Queue is locked.")