def retrieve_work_item( visibility_timeout = None, max_wait_time = None, interrupt_func = None, auto_get_asset = True ): """ Retrieve the next work item from the queue. """ try: if visibility_timeout is None: visibility_timeout = settings.SQS_VISIBILITY_TIMEOUT message = sqs.get_message( visibility_timeout = visibility_timeout, max_wait_time = max_wait_time, interrupt_func = interrupt_func ) if message and auto_get_asset: message.update(instantiate_asset(message['Asset-ID'])) return message except: return None
def test_post_message(self): sqs.clear_all_messages() received = sqs.get_message(max_wait_time=10) self.assert_(received is None, 'Queue should be empty') original = {'body': r'This is a test message\nWith two lines\n'} sqs.post_message(original) received = sqs.get_message(max_wait_time=10, visibility_timeout=5) self.assert_(received is not None) self.assert_(received['body'] == original['body']) sqs.delete_message(received) self.assert_(sqs.get_message(max_wait_time=15) is None)
def test_post_message(self): sqs.clear_all_messages() received = sqs.get_message( max_wait_time = 10) self.assert_( received is None, 'Queue should be empty' ) original = { 'body' : r'This is a test message\nWith two lines\n' } sqs.post_message( original ) received = sqs.get_message( max_wait_time = 10, visibility_timeout = 5 ) self.assert_( received is not None ) self.assert_( received['body'] == original['body'] ) sqs.delete_message(received) self.assert_( sqs.get_message( max_wait_time = 15 ) is None )
def retrieve_work_item(visibility_timeout=None, max_wait_time=None, interrupt_func=None, auto_get_asset=True): """ Retrieve the next work item from the queue. """ try: if visibility_timeout is None: visibility_timeout = settings.SQS_VISIBILITY_TIMEOUT message = sqs.get_message(visibility_timeout=visibility_timeout, max_wait_time=max_wait_time, interrupt_func=interrupt_func) if message and auto_get_asset: message.update(instantiate_asset(message['Asset-ID'])) return message except: return None