# Buggy code
def ready(self):
    from kolibri.tasks.api import client

    client.clear(force=True)


# Traceback (exceptions.TypeError)
osboxes@osboxes:~$ cd Desktop/
osboxes@osboxes:~/Desktop$ ./kolibri-v0.5.0-beta1.pex start
INFO     Kolibri running for the first time.
INFO     We don't yet use pre-migrated database seeds, so you're going to have to wait a bit while we create a blank database...


Operations to perform:
Apply all migrations: sessions, admin, kolibriauth, morango, auth, content, contenttypes, exams, logger
Running migrations:
Rendering model states... DONE
Applying kolibriauth.0001_initial... OK
Applying contenttypes.0001_initial... OK
Applying admin.0001_initial... OK
Applying admin.0002_logentry_remove_auto_add... OK
Applying contenttypes.0002_remove_content_type_name... OK
Applying auth.0001_initial... OK
Applying auth.0002_alter_permission_name_max_length... OK
Applying auth.0003_alter_user_email_max_length... OK
Applying auth.0004_alter_user_username_opts... OK
Applying auth.0005_alter_user_last_login_null... OK
Applying auth.0006_require_contenttypes_0002... OK
Applying auth.0007_alter_validators_add_error_messages... OK
Applying content.0001_initial... OK
Applying content.0002_channelmetadatacache_last_updated... OK
Applying content.0003_auto_20170607_1212... OK
Applying exams.0001_initial... OK
Applying kolibriauth.0002_auto_20170608_2125... OK
Applying kolibriauth.0003_auto_20170621_0958... OK
Applying logger.0001_initial... OK
Applying logger.0002_auto_20170518_1031... OK
Applying logger.0003_auto_20170531_1140... OK
Applying morango.0001_initial... OK
Applying morango.0002_auto_20170511_0400... OK
Applying morango.0003_auto_20170519_0543... OK
Applying morango.0004_auto_20170520_2112... OK
Applying morango.0005_auto_20170629_2139... OK
Applying morango.0006_instanceidmodel_system_id... OK
Applying sessions.0001_initial... OK
Operations to perform:
Apply all migrations: sessions, admin, kolibriauth, morango, auth, content, contenttypes, exams, logger
Running migrations:
Rendering model states... DONE
Applying kolibriauth.0001_initial... OK
Applying contenttypes.0001_initial... OK
Applying admin.0001_initial... OK
Applying admin.0002_logentry_remove_auto_add... OK
Applying contenttypes.0002_remove_content_type_name... OK
Applying auth.0001_initial... OK
Applying auth.0002_alter_permission_name_max_length... OK
Applying auth.0003_alter_user_email_max_length... OK
Applying auth.0004_alter_user_username_opts... OK
Applying auth.0005_alter_user_last_login_null... OK
Applying auth.0006_require_contenttypes_0002... OK
Applying auth.0007_alter_validators_add_error_messages... OK
Applying content.0001_initial... OK
Applying content.0002_channelmetadatacache_last_updated... OK
Applying content.0003_auto_20170607_1212... OK
Applying exams.0001_initial... OK
Applying kolibriauth.0002_auto_20170608_2125... OK
Applying kolibriauth.0003_auto_20170621_0958... OK
Applying logger.0001_initial... OK
Applying logger.0002_auto_20170518_1031... OK
Applying logger.0003_auto_20170531_1140... OK
Applying morango.0001_initial... OK
Applying morango.0002_auto_20170511_0400... OK
Applying morango.0003_auto_20170519_0543... OK
Applying morango.0004_auto_20170520_2112... OK
Applying morango.0005_auto_20170629_2139... OK
Applying morango.0006_instanceidmodel_system_id... OK
Applying sessions.0001_initial... OK
INFO     Automatically enabling applications.
INFO:kolibri.utils.cli:Automatically enabling applications.
INFO     Running update routines for new version...
INFO:kolibri.utils.cli:Running update routines for new version...
Copying '/home/osboxes/.pex/install/kolibri-0.5.0b1-py2.py3-none-any.whl.b0cce2f7791692dbc00cbf6d667637d4c24cc0b5/kolibri-0.5.0b1-py2.py3-none-any.whl/kolibri/core/static/default_frontend/3-0.5.0beta1.js'
Copying '/home/osboxes/.pex/install/kolibri-0.5.0b1-py2.py3-none-any.whl.b0cce2f7791692dbc00cbf6d667637d4c24cc0b5/kolibri-0.5.0b1-py2.py3-none-any.whl/kolibri/core/static/default_frontend/4-0.5.0beta1.js'

...

Copying '/home/osboxes/.pex/install/kolibri-0.5.0b1-py2.py3-none-any.whl.b0cce2f7791692dbc00cbf6d667637d4c24cc0b5/kolibri-0.5.0b1-py2.py3-none-any.whl/kolibri/dist/kolibri_exercise_perseus_plugin/static/mathjax/2.1/config/KAthJax-e76365d62c31e1cbafe939bf94aa8497.js'

377 static files copied to '/home/osboxes/.kolibri/static'.
Operations to perform:
Apply all migrations: sessions, admin, kolibriauth, morango, auth, content, contenttypes, exams, logger
Running migrations:
No migrations to apply.
Your models have changes that are not yet reflected in a migration, and so won't be applied.
Run 'manage.py makemigrations' to make new migrations, and then re-run 'manage.py migrate' to apply them.
Operations to perform:
Apply all migrations: sessions, admin, kolibriauth, morango, auth, content, contenttypes, exams, logger
Running migrations:
No migrations to apply.
Your models have changes that are not yet reflected in a migration, and so won't be applied.
Run 'manage.py makemigrations' to make new migrations, and then re-run 'manage.py migrate' to apply them.
INFO     Running 'kolibri start' as daemon (system service)
INFO:kolibri.utils.cli:Running 'kolibri start' as daemon (system service)
INFO     Going to daemon mode, logging to /home/osboxes/.kolibri/server.log
INFO:kolibri.utils.cli:Going to daemon mode, logging to /home/osboxes/.kolibri/server.log
Exception in thread MESSAGEPROCESSOR-bluebird-uniform-yellow-fifteen (most likely raised during interpreter shutdown):Exception in thread WORKERMESSAGEHANDLER-missouri-pip-football-moon (most likely raised during interpreter shutdown):Exception in thread SCHEDULER-wolfram-mobile-victor-gee (most likely raised during interpreter shutdown):

Traceback (most recent call last):Traceback (most recent call last):

File "/usr/lib/python2.7/threading.py", line 801, in __bootstrap_inner  File "/usr/lib/python2.7/threading.py", line 801, in __bootstrap_inner


File "/home/osboxes/.pex/install/kolibri-0.5.0b1-py2.py3-none-any.whl.b0cce2f7791692dbc00cbf6d667637d4c24cc0b5/kolibri-0.5.0b1-py2.py3-none-any.whl/kolibri/dist/barbequeue/common/utils.py", line 53, in runTraceback (most recent call last):  File "/home/osboxes/.pex/install/kolibri-0.5.0b1-py2.py3-none-any.whl.b0cce2f7791692dbc00cbf6d667637d4c24cc0b5/kolibri-0.5.0b1-py2.py3-none-any.whl/kolibri/dist/barbequeue/common/utils.py", line 53, in run


File "/usr/lib/python2.7/threading.py", line 614, in wait  File "/usr/lib/python2.7/threading.py", line 801, in __bootstrap_inner  File "/usr/lib/python2.7/threading.py", line 614, in wait


File "/usr/lib/python2.7/threading.py", line 355, in wait  File "/home/osboxes/.pex/install/kolibri-0.5.0b1-py2.py3-none-any.whl.b0cce2f7791692dbc00cbf6d667637d4c24cc0b5/kolibri-0.5.0b1-py2.py3-none-any.whl/kolibri/dist/barbequeue/common/utils.py", line 53, in run  File "/usr/lib/python2.7/threading.py", line 355, in wait


<type 'exceptions.TypeError'>: 'NoneType' object is not callable  File "/usr/lib/python2.7/threading.py", line 614, in wait<type 'exceptions.TypeError'>: 'NoneType' object is not callable


File "/usr/lib/python2.7/threading.py", line 355, in wait
<type 'exceptions.TypeError'>: 'NoneType' object is not callable
osboxes@osboxes:~/Desktop$

# Fixed code
def ready(self):
    global client
    client = SimpleClient(app="kolibri", storage_path=settings.QUEUE_JOB_STORAGE_PATH)
    client.clear(force=True)