<s> from __future__ import ( absolute_import , division , print_function , <EOL> unicode_literals ) <EOL> from tests import RQTestCase <EOL> from tests . fixtures import ( div_by_zero , echo , Number , say_hello , <EOL> some_calculation ) <EOL> from rq import get_failed_queue , Queue <EOL> from rq . exceptions import InvalidJobOperationError <EOL> from rq . job import Job , JobStatus <EOL> from rq . registry import DeferredJobRegistry <EOL> from rq . worker import Worker <EOL> class CustomJob ( Job ) : <EOL> pass <EOL> class TestQueue ( RQTestCase ) : <EOL> def test_create_queue ( self ) : <EOL> """<STR_LIT>""" <EOL> q = Queue ( '<STR_LIT>' ) <EOL> self . assertEqual ( q . name , '<STR_LIT>' ) <EOL> def test_create_default_queue ( self ) : <EOL> """<STR_LIT>""" <EOL> q = Queue ( ) <EOL> self . assertEqual ( q . name , '<STR_LIT:default>' ) <EOL> def test_equality ( self ) : <EOL> """<STR_LIT>""" <EOL> q1 = Queue ( '<STR_LIT:foo>' ) <EOL> q2 = Queue ( '<STR_LIT:foo>' ) <EOL> q3 = Queue ( '<STR_LIT:bar>' ) <EOL> self . assertEqual ( q1 , q2 ) <EOL> self . assertEqual ( q2 , q1 ) <EOL> self . assertNotEqual ( q1 , q3 ) <EOL> self . assertNotEqual ( q2 , q3 ) <EOL> def test_empty_queue ( self ) : <EOL> """<STR_LIT>""" <EOL> q = Queue ( '<STR_LIT>' ) <EOL> self . testconn . rpush ( '<STR_LIT>' , '<STR_LIT:foo>' ) <EOL> self . testconn . rpush ( '<STR_LIT>' , '<STR_LIT:bar>' ) <EOL> self . assertEqual ( q . is_empty ( ) , False ) <EOL> q . empty ( ) <EOL> self . assertEqual ( q . is_empty ( ) , True ) <EOL> self . assertIsNone ( self . testconn . lpop ( '<STR_LIT>' ) ) <EOL> def test_empty_removes_jobs ( self ) : <EOL> """<STR_LIT>""" <EOL> q = Queue ( '<STR_LIT>' ) <EOL> job = q . enqueue ( say_hello ) <EOL> self . assertTrue ( Job . exists ( job . id ) ) <EOL> q . empty ( ) <EOL> self . assertFalse ( Job . exists ( job . id ) ) <EOL> def test_queue_is_empty ( self ) : <EOL> """<STR_LIT>""" <EOL> q = Queue ( '<STR_LIT>' ) <EOL> self . assertEqual ( q . is_empty ( ) , True ) <EOL> self . testconn . rpush ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> self . assertEqual ( q . is_empty ( ) , False ) <EOL> def test_remove ( self ) : <EOL> """<STR_LIT>""" <EOL> q = Queue ( '<STR_LIT>' ) <EOL> job = q . enqueue ( say_hello ) <EOL> self . assertIn ( job . id , q . job_ids ) <EOL> q . remove ( job ) <EOL> self . assertNotIn ( job . id , q . job_ids ) <EOL> job = q . enqueue ( say_hello ) <EOL> self . assertIn ( job . id , q . job_ids ) <EOL> q . remove ( job . id ) <EOL> self . assertNotIn ( job . id , q . job_ids ) <EOL> def test_jobs ( self ) : <EOL> """<STR_LIT>""" <EOL> q = Queue ( '<STR_LIT>' ) <EOL> self . assertEqual ( q . jobs , [ ] ) <EOL> job = q . enqueue ( say_hello ) <EOL> self . assertEqual ( q . jobs , [ job ] ) <EOL> job . delete ( ) <EOL> self . assertEqual ( q . job_ids , [ ] ) <EOL> def test_compact ( self ) : <EOL> """<STR_LIT>""" <EOL> q = Queue ( ) <EOL> q . enqueue ( say_hello , '<STR_LIT>' ) <EOL> q . enqueue ( say_hello , '<STR_LIT>' ) <EOL> self . testconn . lpush ( q . key , '<STR_LIT:1>' , '<STR_LIT:2>' ) <EOL> self . assertEqual ( q . count , <NUM_LIT:4> ) <EOL> self . assertEqual ( len ( q ) , <NUM_LIT:4> ) <EOL> q . compact ( ) <EOL> self . assertEqual ( q . count , <NUM_LIT:2> ) <EOL> self . assertEqual ( len ( q ) , <NUM_LIT:2> ) <EOL> def test_enqueue ( self ) : <EOL> """<STR_LIT>""" <EOL> q = Queue ( ) <EOL> self . assertEqual ( q . is_empty ( ) , True ) <EOL> job = q . enqueue ( say_hello , '<STR_LIT>' , foo = '<STR_LIT:bar>' ) <EOL> job_id = job . id <EOL> self . assertEqual ( job . origin , q . name ) <EOL> q_key = '<STR_LIT>' <EOL> self . assertEqual ( self . testconn . llen ( q_key ) , <NUM_LIT:1> ) <EOL> self . assertEqual ( <EOL> self . testconn . lrange ( q_key , <NUM_LIT:0> , - <NUM_LIT:1> ) [ <NUM_LIT:0> ] . decode ( '<STR_LIT:ascii>' ) , <EOL> job_id ) <EOL> def test_enqueue_sets_metadata ( self ) : <EOL> """<STR_LIT>""" <EOL> q = Queue ( ) <EOL> job = Job . create ( func = say_hello , args = ( '<STR_LIT>' , ) , kwargs = dict ( foo = '<STR_LIT:bar>' ) ) <EOL> self . assertIsNone ( job . enqueued_at ) <EOL> q . enqueue_job ( job ) <EOL> self . assertIsNotNone ( job . enqueued_at ) <EOL> def test_pop_job_id ( self ) : <EOL> """<STR_LIT>""" <EOL> q = Queue ( ) <EOL> uuid = '<STR_LIT>' <EOL> q . push_job_id ( uuid ) <EOL> self . assertEqual ( q . count , <NUM_LIT:1> ) <EOL> self . assertEqual ( q . pop_job_id ( ) , uuid ) <EOL> self . assertEqual ( q . count , <NUM_LIT:0> ) <EOL> def test_dequeue ( self ) : <EOL> """<STR_LIT>""" <EOL> q = Queue ( ) <EOL> result = q . enqueue ( say_hello , '<STR_LIT>' , foo = '<STR_LIT:bar>' ) <EOL> self . assertEqual ( q . count , <NUM_LIT:1> ) <EOL> job = q . dequeue ( ) <EOL> self . assertEqual ( job . id , result . id ) <EOL> self . assertEqual ( job . func , say_hello ) <EOL> self . assertEqual ( job . origin , q . name ) <EOL> self . assertEqual ( job . args [ <NUM_LIT:0> ] , '<STR_LIT>' ) <EOL> self . assertEqual ( job . kwargs [ '<STR_LIT:foo>' ] , '<STR_LIT:bar>' ) <EOL> self . assertEqual ( q . count , <NUM_LIT:0> ) <EOL> def test_dequeue_deleted_jobs ( self ) : <EOL> """<STR_LIT>""" <EOL> q = Queue ( ) <EOL> for _ in range ( <NUM_LIT:1> , <NUM_LIT:1000> ) : <EOL> job = q . enqueue ( say_hello ) <EOL> job . delete ( ) <EOL> q . dequeue ( ) <EOL> def test_dequeue_instance_method ( self ) : <EOL> """<STR_LIT>""" <EOL> q = Queue ( ) <EOL> n = Number ( <NUM_LIT:2> ) <EOL> q . enqueue ( n . div , <NUM_LIT:4> ) <EOL> job = q . dequeue ( ) <EOL> self . assertEqual ( job . instance . __dict__ , n . __dict__ ) <EOL> self . assertEqual ( job . func . __name__ , '<STR_LIT>' ) <EOL> self . assertEqual ( job . args , ( <NUM_LIT:4> , ) ) <EOL> def test_dequeue_class_method ( self ) : <EOL> """<STR_LIT>""" <EOL> q = Queue ( ) <EOL> q . enqueue ( Number . divide , <NUM_LIT:3> , <NUM_LIT:4> ) <EOL> job = q . dequeue ( ) <EOL> self . assertEqual ( job . instance . __dict__ , Number . __dict__ ) <EOL> self . assertEqual ( job . func . __name__ , '<STR_LIT>' ) <EOL> self . assertEqual ( job . args , ( <NUM_LIT:3> , <NUM_LIT:4> ) ) <EOL> def test_dequeue_ignores_nonexisting_jobs ( self ) : <EOL> """<STR_LIT>""" <EOL> q = Queue ( ) <EOL> uuid = '<STR_LIT>' <EOL> q . push_job_id ( uuid ) <EOL> q . push_job_id ( uuid ) <EOL> result = q . enqueue ( say_hello , '<STR_LIT>' , foo = '<STR_LIT:bar>' ) <EOL> q . push_job_id ( uuid ) <EOL> self . assertEqual ( q . count , <NUM_LIT:4> ) <EOL> self . assertEqual ( q . dequeue ( ) . id , result . id ) <EOL> self . assertIsNone ( q . dequeue ( ) ) <EOL> self . assertEqual ( q . count , <NUM_LIT:0> ) <EOL> def test_dequeue_any ( self ) : <EOL> """<STR_LIT>""" <EOL> fooq = Queue ( '<STR_LIT:foo>' ) <EOL> barq = Queue ( '<STR_LIT:bar>' ) <EOL> self . assertEqual ( Queue . dequeue_any ( [ fooq , barq ] , None ) , None ) <EOL> barq . enqueue ( say_hello ) <EOL> job , queue = Queue . dequeue_any ( [ fooq , barq ] , None ) <EOL> self . assertEqual ( job . func , say_hello ) <EOL> self . assertEqual ( queue , barq ) <EOL> barq . enqueue ( say_hello , '<STR_LIT>' ) <EOL> fooq . enqueue ( say_hello , '<STR_LIT>' ) <EOL> job , queue = Queue . dequeue_any ( [ fooq , barq ] , None ) <EOL> self . assertEqual ( queue , fooq ) <EOL> self . assertEqual ( job . func , say_hello ) <EOL> self . assertEqual ( job . origin , fooq . name ) <EOL> self . assertEqual ( job . args [ <NUM_LIT:0> ] , '<STR_LIT>' , <EOL> '<STR_LIT>' ) <EOL> job , queue = Queue . dequeue_any ( [ fooq , barq ] , None ) <EOL> self . assertEqual ( queue , barq ) <EOL> self . assertEqual ( job . func , say_hello ) <EOL> self . assertEqual ( job . origin , barq . name ) <EOL> self . assertEqual ( job . args [ <NUM_LIT:0> ] , '<STR_LIT>' , <EOL> '<STR_LIT>' ) <EOL> def test_dequeue_any_ignores_nonexisting_jobs ( self ) : <EOL> """<STR_LIT>""" <EOL> q = Queue ( '<STR_LIT>' ) <EOL> uuid = '<STR_LIT>' <EOL> q . push_job_id ( uuid ) <EOL> self . assertEqual ( q . count , <NUM_LIT:1> ) <EOL> self . assertEqual ( Queue . dequeue_any ( [ Queue ( ) , Queue ( '<STR_LIT>' ) ] , None ) , <EOL> None ) <EOL> self . assertEqual ( q . count , <NUM_LIT:0> ) <EOL> def test_enqueue_sets_status ( self ) : <EOL> """<STR_LIT>""" <EOL> q = Queue ( ) <EOL> job = q . enqueue ( say_hello ) <EOL> self . assertEqual ( job . get_status ( ) , JobStatus . QUEUED ) <EOL> def test_enqueue_meta_arg ( self ) : <EOL> """<STR_LIT>""" <EOL> q = Queue ( ) <EOL> job = q . enqueue ( say_hello , meta = { '<STR_LIT:foo>' : '<STR_LIT:bar>' , '<STR_LIT>' : <NUM_LIT> } ) <EOL> self . assertEqual ( job . meta [ '<STR_LIT:foo>' ] , '<STR_LIT:bar>' ) <EOL> self . assertEqual ( job . meta [ '<STR_LIT>' ] , <NUM_LIT> ) <EOL> def test_enqueue_explicit_args ( self ) : <EOL> """<STR_LIT>""" <EOL> q = Queue ( ) <EOL> job = q . enqueue ( echo , <NUM_LIT:1> , timeout = <NUM_LIT:1> , result_ttl = <NUM_LIT:1> , bar = '<STR_LIT>' ) <EOL> self . assertEqual ( job . timeout , <NUM_LIT:1> ) <EOL> self . assertEqual ( job . result_ttl , <NUM_LIT:1> ) <EOL> self . assertEqual ( <EOL> job . perform ( ) , <EOL> ( ( <NUM_LIT:1> , ) , { '<STR_LIT:bar>' : '<STR_LIT>' } ) <EOL> ) <EOL> kwargs = { <EOL> '<STR_LIT>' : <NUM_LIT:1> , <EOL> '<STR_LIT>' : <NUM_LIT:1> , <EOL> } <EOL> job = q . enqueue ( echo , timeout = <NUM_LIT:2> , result_ttl = <NUM_LIT:2> , args = [ <NUM_LIT:1> ] , kwargs = kwargs ) <EOL> self . assertEqual ( job . timeout , <NUM_LIT:2> ) <EOL> self . assertEqual ( job . result_ttl , <NUM_LIT:2> ) <EOL> self . assertEqual ( <EOL> job . perform ( ) , <EOL> ( ( <NUM_LIT:1> , ) , { '<STR_LIT>' : <NUM_LIT:1> , '<STR_LIT>' : <NUM_LIT:1> } ) <EOL> ) <EOL> def test_all_queues ( self ) : <EOL> """<STR_LIT>""" <EOL> q1 = Queue ( '<STR_LIT>' ) <EOL> q2 = Queue ( '<STR_LIT>' ) <EOL> q3 = Queue ( '<STR_LIT>' ) <EOL> self . assertEqual ( len ( Queue . all ( ) ) , <NUM_LIT:0> ) <EOL> q1 . enqueue ( say_hello ) <EOL> self . assertEqual ( len ( Queue . all ( ) ) , <NUM_LIT:1> ) <EOL> q2 . enqueue ( say_hello ) <EOL> q3 . enqueue ( say_hello ) <EOL> names = [ q . name for q in Queue . all ( ) ] <EOL> self . assertEqual ( len ( Queue . all ( ) ) , <NUM_LIT:3> ) <EOL> self . assertTrue ( '<STR_LIT>' in names ) <EOL> self . assertTrue ( '<STR_LIT>' in names ) <EOL> self . assertTrue ( '<STR_LIT>' in names ) <EOL> w = Worker ( [ q2 , q3 ] ) <EOL> w . work ( burst = True ) <EOL> self . assertEqual ( len ( Queue . all ( ) ) , <NUM_LIT:3> ) <EOL> def test_enqueue_dependents ( self ) : <EOL> """<STR_LIT>""" <EOL> q = Queue ( ) <EOL> parent_job = Job . create ( func = say_hello ) <EOL> parent_job . save ( ) <EOL> job_1 = q . enqueue ( say_hello , depends_on = parent_job ) <EOL> job_2 = q . enqueue ( say_hello , depends_on = parent_job ) <EOL> registry = DeferredJobRegistry ( q . name , connection = self . testconn ) <EOL> self . assertEqual ( <EOL> set ( registry . get_job_ids ( ) ) , <EOL> set ( [ job_1 . id , job_2 . id ] ) <EOL> ) <EOL> self . assertEqual ( q . job_ids , [ ] ) <EOL> q . enqueue_dependents ( parent_job ) <EOL> self . assertEqual ( set ( q . job_ids ) , set ( [ job_2 . id , job_1 . id ] ) ) <EOL> self . assertFalse ( self . testconn . exists ( parent_job . dependents_key ) ) <EOL> self . assertEqual ( registry . get_job_ids ( ) , [ ] ) <EOL> def test_enqueue_dependents_on_multiple_queues ( self ) : <EOL> """<STR_LIT>""" <EOL> q_1 = Queue ( "<STR_LIT>" ) <EOL> q_2 = Queue ( "<STR_LIT>" ) <EOL> parent_job = Job . create ( func = say_hello ) <EOL> parent_job . save ( ) <EOL> job_1 = q_1 . enqueue ( say_hello , depends_on = parent_job ) <EOL> job_2 = q_2 . enqueue ( say_hello , depends_on = parent_job ) <EOL> registry_1 = DeferredJobRegistry ( q_1 . name , connection = self . testconn ) <EOL> self . assertEqual ( <EOL> set ( registry_1 . get_job_ids ( ) ) , <EOL> set ( [ job_1 . id ] ) <EOL> ) <EOL> registry_2 = DeferredJobRegistry ( q_2 . name , connection = self . testconn ) <EOL> self . assertEqual ( <EOL> set ( registry_2 . get_job_ids ( ) ) , <EOL> set ( [ job_2 . id ] ) <EOL> ) <EOL> self . assertEqual ( q_1 . job_ids , [ ] ) <EOL> self . assertEqual ( q_2 . job_ids , [ ] ) <EOL> q_1 . enqueue_dependents ( parent_job ) <EOL> q_2 . enqueue_dependents ( parent_job ) <EOL> self . assertEqual ( set ( q_1 . job_ids ) , set ( [ job_1 . id ] ) ) <EOL> self . assertEqual ( set ( q_2 . job_ids ) , set ( [ job_2 . id ] ) ) <EOL> self . assertFalse ( self . testconn . exists ( parent_job . dependents_key ) ) <EOL> self . assertEqual ( registry_1 . get_job_ids ( ) , [ ] ) <EOL> self . assertEqual ( registry_2 . get_job_ids ( ) , [ ] ) <EOL> def test_enqueue_job_with_dependency ( self ) : <EOL> """<STR_LIT>""" <EOL> parent_job = Job . create ( func = say_hello ) <EOL> q = Queue ( ) <EOL> job = q . enqueue_call ( say_hello , depends_on = parent_job ) <EOL> self . assertEqual ( q . job_ids , [ ] ) <EOL> self . assertEqual ( job . get_status ( ) , JobStatus . DEFERRED ) <EOL> parent_job . set_status ( JobStatus . FINISHED ) <EOL> parent_job . save ( ) <EOL> job = q . enqueue_call ( say_hello , depends_on = parent_job ) <EOL> self . assertEqual ( q . job_ids , [ job . id ] ) <EOL> self . assertEqual ( job . timeout , Queue . DEFAULT_TIMEOUT ) <EOL> self . assertEqual ( job . get_status ( ) , JobStatus . QUEUED ) <EOL> def test_enqueue_job_with_dependency_by_id ( self ) : <EOL> """<STR_LIT>""" <EOL> parent_job = Job . create ( func = say_hello ) <EOL> q = Queue ( ) <EOL> q . enqueue_call ( say_hello , depends_on = parent_job . id ) <EOL> self . assertEqual ( q . job_ids , [ ] ) <EOL> parent_job . set_status ( JobStatus . FINISHED ) <EOL> parent_job . save ( ) <EOL> job = q . enqueue_call ( say_hello , depends_on = parent_job . id ) <EOL> self . assertEqual ( q . job_ids , [ job . id ] ) <EOL> self . assertEqual ( job . timeout , Queue . DEFAULT_TIMEOUT ) <EOL> def test_enqueue_job_with_dependency_and_timeout ( self ) : <EOL> """<STR_LIT>""" <EOL> parent_job = Job . create ( func = say_hello ) <EOL> q = Queue ( ) <EOL> job = q . enqueue_call ( say_hello , depends_on = parent_job , timeout = <NUM_LIT> ) <EOL> self . assertEqual ( q . job_ids , [ ] ) <EOL> self . assertEqual ( job . timeout , <NUM_LIT> ) <EOL> parent_job . set_status ( JobStatus . FINISHED ) <EOL> parent_job . save ( ) <EOL> job = q . enqueue_call ( say_hello , depends_on = parent_job , timeout = <NUM_LIT> ) <EOL> self . assertEqual ( q . job_ids , [ job . id ] ) <EOL> self . assertEqual ( job . timeout , <NUM_LIT> ) <EOL> class TestFailedQueue ( RQTestCase ) : <EOL> def test_requeue_job ( self ) : <EOL> """<STR_LIT>""" <EOL> job = Job . create ( func = div_by_zero , args = ( <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> ) ) <EOL> job . origin = '<STR_LIT>' <EOL> job . save ( ) <EOL> get_failed_queue ( ) . quarantine ( job , Exception ( '<STR_LIT>' ) ) <EOL> self . assertEqual ( Queue . all ( ) , [ get_failed_queue ( ) ] ) <EOL> self . assertEqual ( get_failed_queue ( ) . count , <NUM_LIT:1> ) <EOL> get_failed_queue ( ) . requeue ( job . id ) <EOL> self . assertEqual ( get_failed_queue ( ) . count , <NUM_LIT:0> ) <EOL> self . assertEqual ( Queue ( '<STR_LIT>' ) . count , <NUM_LIT:1> ) <EOL> def test_requeue_nonfailed_job_fails ( self ) : <EOL> """<STR_LIT>""" <EOL> q = Queue ( ) <EOL> job = q . enqueue ( say_hello , '<STR_LIT>' , foo = '<STR_LIT:bar>' ) <EOL> with self . assertRaises ( InvalidJobOperationError ) : <EOL> get_failed_queue ( ) . requeue ( job . id ) <EOL> def test_quarantine_preserves_timeout ( self ) : <EOL> """<STR_LIT>""" <EOL> job = Job . create ( func = div_by_zero , args = ( <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> ) ) <EOL> job . origin = '<STR_LIT>' <EOL> job . timeout = <NUM_LIT:200> <EOL> job . save ( ) <EOL> get_failed_queue ( ) . quarantine ( job , Exception ( '<STR_LIT>' ) ) <EOL> self . assertEqual ( job . timeout , <NUM_LIT:200> ) <EOL> def test_requeueing_preserves_timeout ( self ) : <EOL> """<STR_LIT>""" <EOL> job = Job . create ( func = div_by_zero , args = ( <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> ) ) <EOL> job . origin = '<STR_LIT>' <EOL> job . timeout = <NUM_LIT:200> <EOL> job . save ( ) <EOL> get_failed_queue ( ) . quarantine ( job , Exception ( '<STR_LIT>' ) ) <EOL> get_failed_queue ( ) . requeue ( job . id ) <EOL> job = Job . fetch ( job . id ) <EOL> self . assertEqual ( job . timeout , <NUM_LIT:200> ) <EOL> def test_requeue_sets_status_to_queued ( self ) : <EOL> """<STR_LIT>""" <EOL> job = Job . create ( func = div_by_zero , args = ( <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> ) ) <EOL> job . save ( ) <EOL> get_failed_queue ( ) . quarantine ( job , Exception ( '<STR_LIT>' ) ) <EOL> get_failed_queue ( ) . requeue ( job . id ) <EOL> job = Job . fetch ( job . id ) <EOL> self . assertEqual ( job . get_status ( ) , JobStatus . QUEUED ) <EOL> def test_enqueue_preserves_result_ttl ( self ) : <EOL> """<STR_LIT>""" <EOL> q = Queue ( ) <EOL> job = q . enqueue ( div_by_zero , args = ( <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> ) , result_ttl = <NUM_LIT:10> ) <EOL> self . assertEqual ( job . result_ttl , <NUM_LIT:10> ) <EOL> job_from_queue = Job . fetch ( job . id , connection = self . testconn ) <EOL> self . assertEqual ( int ( job_from_queue . result_ttl ) , <NUM_LIT:10> ) <EOL> def test_async_false ( self ) : <EOL> """<STR_LIT>""" <EOL> q = Queue ( async = False ) <EOL> job = q . enqueue ( some_calculation , args = ( <NUM_LIT:2> , <NUM_LIT:3> ) ) <EOL> self . assertEqual ( job . return_value , <NUM_LIT:6> ) <EOL> self . assertNotEqual ( self . testconn . ttl ( job . key ) , - <NUM_LIT:1> ) <EOL> def test_custom_job_class ( self ) : <EOL> """<STR_LIT>""" <EOL> q = Queue ( job_class = CustomJob ) <EOL> self . assertEqual ( q . job_class , CustomJob ) <EOL> def test_skip_queue ( self ) : <EOL> """<STR_LIT>""" <EOL> q = Queue ( '<STR_LIT:foo>' ) <EOL> job1 = q . enqueue ( say_hello ) <EOL> job2 = q . enqueue ( say_hello ) <EOL> assert q . dequeue ( ) == job1 <EOL> skip_job = q . enqueue ( say_hello , at_front = True ) <EOL> assert q . dequeue ( ) == skip_job <EOL> assert q . dequeue ( ) == job2 </s>
