Question#1 Celery is a package available in __________.
a) Pandas
b) NumPy
c) PyPI
d) SciPy
Answer:- PyPI
Question#2 To run RabbitMQ in the background, use ________.
a) $ sudo rabbitmq-server -background
b) $ sudo rabbitmq-server -b
c) $ sudo rabbitmq-server -detached
d) $ sudo rabbitmq-server -attach
Answer:- $ sudo rabbitmq-server -detached
Question#3 A client process ___________.
a) subscribes to task queues to perform work
b) puts work requests into queues
c) puts work requests into queues and fetches results from the backend
d) fetches results from the backend
e) All the options
Answer:- puts work requests into queues and fetches results from the backend
Question#4 Celery protocol can be implemented in any language.
a) True
b) False
Answer:- True
Question#5 Using rpc:// result backend, two processes can wait for the same result.
a) True
b) False
Answer:- False
Question#6 Name the broker in the following.
app = Celery(‘tasks’, broker=’pyamqp://guest@localhost//’).
a) Redis
b) RabbitMQ
c) Amazon SQS
d) None of the options
Answer:- RabbitMQ
Question#7 If app=celery(), task is created using _______ decorator.
a) app
b) @app.task
c) @task.app
d) All the options
Answer:- @app.task
Question#8 If a task raises an exception, we can override it using __________.
a) result.get(propagate=True)
b) result.get(propagate=False)
c) result.get(exception=True)
d) result.get(exception=False)
Answer:- result.get(propagate=False)
Question#9 If the following configuration is used, which of the following is used for broker and backend?
broker_url = ‘pyamqp://’
result_backend = ‘rpc://’.
a) Broker is Redis, backend is RabbitMQ
b) Both broker and backend are RabbitMQ
c) Both broker and backend are Redis
d) Broker is RabbitMQ, backend is Redis
Answer:- Both broker and backend are RabbitMQ
Question#10 Which of the following calling APIs is/are supported by celery task instances?
a) calling
b) delay
c) apply_async
d) All the options
Answer:- All the options
Question#11 Consider the following.
<<< from celery import Celery
<<< app = Celery()
What does app have?
a) Memory address of the object
b) Name of the current main module
c) Name of the app class
d) All the options
Answer:- Memory address of the object
Question#12 Celery has the following defined default result states, except _______.
a) STARTED
b) RUNNING
c) PENDING
d) RETRY
Answer:- RUNNING
Question#13 Consider a task T. Write the code to execute in 10 seconds from now, specified using ETA.
a) T.apply_async(ETA=now + timedelta(seconds=10))
b) T.apply_async(ETA=now + timedelta(10))
c) T.apply_async(eta=now + timedelta(seconds=10))
d) T.apply_async(countdown=10)
Answer:- T.apply_async(ETA=now + timedelta(seconds=10))
Question#14 Consider a file tasks.py with:
@app.task
def add(x, y):
return x + y
After executing:
from tasks import add
What will be the output of:
<<< add.name
a) error
b) tasks.add’
c) name not defined
d) None of the options
Answer:- tasks.add’
Question#15 Celery automatically retries sending messages in the event of a connection failure.
a) True
b) False
Answer:- True
Question#16 celeri multi stores information about workers.
a) True
b) False
Answer:- False
Question#17 If we add the following in celery configuration
task_annotations = {
‘tasks.add’: {‘rate_limit’: ’10/m’}
}
what does it mean
a) mechanism to low prioritize misbehaving queues
b) the task rate limit is set
c) Only 10 tasks of this type can be processed in a minute
d) All the options
Answer:- All the options
Question#18 consider a task T. Write a code to execute in 30 seconds from now, but expires after 3 minutes.
a) T.apply_async(countdown=30, expires=180)
b) T.apply_async(countdown=30, expires=3min)
c) T.apply_async(timedelta(seconds=30), expires=180)
d) T.apply_async(countdown=180, expires=30)
Answer:- T.apply_async(countdown=30, expires=180)
Question#19 To list active queues for the worker w1, use
a) app.control.inspect().active_queues()
b) app.control.inspect([‘w1.local’]).active_queues()
c) both
d) None
Answer:- app.control.inspect([‘w1.local’]).active_queues()
Question#20 What is the default queue in celery
a) Redis
b) default
c) RabbitMQ
d) celery
Answer:- celery
Question#21 Let
i = app.control.inspect()
To get a list of registered tasks, use
a) i.registered()
b) i.active()
c) i.scheduled()
d) i.reserved()
e) All the options
Answer:- i.registered()
Question#22 To add a consumer to a queue named q1, use
a) app.control.add_consumer(‘q1’, reply=True)
b) app.control.add_consumer(‘q1’, reply=False)
c) app.control.add_consumer(‘q1’, reply=True, destination=[‘
[email protected]’])
d) app.control.add_consumer(‘q1’, reply=False, destination=[‘
[email protected]’])
Answer:- app.control.add_consumer(‘q1’, reply=True)
Question#23 Let
i = app.control.inspect()
To get a list of reserved tasks, use
a) i.reserved()
b) i.registered()
c) i.scheduled()
d) i.active()
Answer:- i.reserved()
Question#24 To divide an iterable work into pieces, use
a) starmap
b) chunks
c) piece
d) chord
Answer:- chunks
Question#25 Consider a chain
res = chain(add.s(4, 4), mul.s(8), mul.s(10))()
where add is defined as a+b and mul is defined as a*b. How can we get intermediate parent results
a) res.parent.parent
b) res.parent.get()
c) res.parent.parent.get()
d) All the options
Answer:- res.parent.parent.get()
Question#26 Map and star-map differ from group in what ways?
a) the operation is parallel
b) only one task message is sent AND the operation is sequential
c) only one task message is sent AND the operation is parallel
d) the operation is sequential
e) only one task message is sent
Answer:- only one task message is sent AND the operation is sequential
Question#27 (group(add.s(i, i) for i in xrange(10)) | xsum.s())().get() is an example of
a) chain
b) group
c) chunk
d) chord
Answer:- chain
Question#28 The GroupResult takes a list of AsyncResult instances and has the following operations.
a) join()
b) revoke()
c) ready()
d) successful()
e) All the options
Answer:- All the options
Celery Interview Question-Answer Part – 2
Write a Commenton Celery Interview Question-Answer Part – 2
Question#1 consider
@app.task
def xsum(numbers):
return sum(numbers)
What is the map equivalent of
@app.task
def
temp():
return [xsum(range(10)), xsum(range(100))]
Assume all needed methods are imported
a) ~xsum.map([range(100), range(100)])
b) ~xsum.map([range(100), range(10)])
c) ~xsum.map([range(10), range(100)])
d) ~xsum.map([range(10), range(10)])
Answer:- ~xsum.map([range(10), range(100)])
Question#2 consider a method
def add(a,b):
return a + b
What is a partial signature?
a) s2 = add.s(2)
b) s2 = sum.s(2, 3)
c) s2 = add.s(2, 3)
d) s2 = sum.s(2)
Answer:- s2 = sum.s(2, 3)
Question#3 Consider a chain
res = chain(add.s(4, 4), mul.s(8), mul.s(10))()
where add is defined as a+b and mul is defined as a*b. How can we get intermediate parent results
a) res.parent.parent.get()
b) res.parent.get()
c) res.parent.parent
d) All the options
Answer:- res.parent.get()
Question#4 To ensure a job runs every 15 mins using crontab(), what should be given?
a) crontab(minute=’15’)
b) crontab(minute=’15,30,45′)
c) crontab(minute=’*/15′)
d) crontab(minute=’15,30,45′) AND crontab(minute=’15’)
Answer:- crontab(minute=’*/15′)
Question#5 When using solar scheduling, what is sunrise event?
a) Execute when the upper edge of the sun appears over the eastern horizon in the morning.
b) Execute at the moment after which the sky is no longer completely dark. This is when the sun is 18 degrees below the horizon.
c) Execute when there’s enough sunlight for the horizon and some objects to be distinguishable; formally, when the sun is 12 degrees below the horizon.
d) Execute when there’s enough light for objects to be distinguishable so that outdoor activities can commence; formally, when the Sun is 6 degrees below the horizon.
Answer:- Execute when the upper edge of the sun appears over the eastern horizon in the morning.
Question#6 Solar events are
a) sunset
b) sunrise
c) dawn
d) dusk
e) All the options
Answer:- All the options
Question#7 To start celery beat service using a custom file is achieved using
a) celery -A proj beat /home/celery/var/run/celerybeat-schedule
b) celery -A proj beat -s /home/celery/var/run/celerybeat-schedule
c) celery -A proj beat -file /home/celery/var/run/celerybeat-schedule
d) celery -A proj beat -f /home/celery/var/run/celerybeat-schedule
Answer:- celery -A proj beat -s /home/celery/var/run/celerybeat-schedule
Question#8 What does the command do
$ celery -A proj inspect query_task id1 id2 … idN
a) show the corresponding queues
b) show the task status of id1 id2 … idN
c) show the workers for the corresponding tasks
d) query information about multiple tasks
Answer:- query information about multiple tasks
Question#9 Worker-hearbeat events are sent every
a) 2 min
b) 1 min
c) 4 min
d) 3 min
Answer:- 1 min
Question#10 Following command gives
$ rabbitmqctl list_queues name memory
a) command not found error
b) amount of memory allocated to queue
c) command options incorrect error
d) number of workers currently consuming from a queue named memory
Answer:- command not found error
Question#11 Django database scheduler can detect timezone changes and automatically reset schedule.
a) True
b) False
Answer:- False
Question#12 What does the command do
$ celery -A proj purge -X celery
a) Purge messages from the celery queue
b) Purge messages from all configured task queues
c) Purge messages from all queues other than celery queue
d) None of the options
Answer:- Purge messages from all queues other than celery queue
Question#13 To process events in real time you need
a) State
b) A set of handlers
c) An event consumer
d) All the options
Answer:- All the options
Question#14 What dependencies does celery have?
a) billiard
b) pytz
c) kombu
d) All the options
Answer:- All the options
Question#15 If app=celery(), task is created using _____ decorator?
a) @task.app
b) app
c) @app.task
d) All the options
Answer:- @app.task
Question#16 To configure a database backend as a result backend, the configuration is
result_backend = ‘db+scheme://user:password@host:port/dbname’
Which databases are supported?
a) mysql and postgresql
b) mysql
c) postgresql
d) oracle
e) All the options
Answer:- All the options
Question#17 consider
app = Celery(‘tasks’, broker=’redis://guest@localhost//’)
Name the broker.
a) Amazon SQS
b) Redis
c) RabbitMQ
d) None of the options
Answer:- Redis
Question#18 What brokers does celery support?
a) RabbitMQ, Oracle Message Broker, IBM Websphere
b) RabbitMQ, Redis, Oracle Message Broker
c) RabbitMQ, Redis, Amazon SQS
d) Oracle Message Broker, IBM Websphere, Redis
Answer:- RabbitMQ, Redis, Amazon SQS
Question#19 heartbeat_sent, worker_init and celeryd_init are ____ signals
a) beat
b) worker
c) eventlet
d) task
Answer:- worker
Question#20 Which are the features of celery
a) time & rate limts
b) Scheduling
c) work-flows
d) Monitoring
e) All the options
Answer:- All the options
Question#21 Celery supports the following serialization
a) pickle
b) YAML
c) JSON
d) msgpack
e) All the options
Answer:- All the options
Question#22 Queues created by celery are ____ by default
a) transient
b) persistent
c) none
d) both
Answer:- persistent
Question#23 Celery uses headers to store the content type of the message and its content encoding.
a) True
b) False
Answer:- True
Question#24 Broadcast routing delivers copies of all tasks to all workers connected to a queue.
a) True
b) False
Answer:- True
Question#25 If no custom application has been initiated, celery always creates a special app. It is called
a) app
b) default
c) special
d) celery
Answer:- celery
Question#26 $ celery -A proj control enable_events
is used to
a) add control events
b) dump events
c) disable event messages
d) enable event messages
Answer:- enable event messages
Question#27 To create a queue not defined on task_queues, use
a) task_create_missing_queue
b) task_create_missing_queues
c) task_create_queues
d) task_create_queue
Answer:- task_create_missing_queues
Question#28 A client sending messages is a
a) consumer
b) publisher
c) Broker is RabbitMQ, backend is Redis
d) None of the options
Answer:- Broker is RabbitMQ, backend is Redis
Question#29 Creating a celery instance will do the following
a) Create a logical clock instance, used for events
b) Create the task registry
c) Set itself as the current app
d) Call the app.on_init() callback
e) All the options
Answer:- All the options