Skip to content

Commit

Permalink
dodal flag USE_CONCURRENCY
Browse files Browse the repository at this point in the history
  • Loading branch information
janezkranjc committed Sep 5, 2012
1 parent 8297545 commit 3c0c144
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 20 deletions.
2 changes: 2 additions & 0 deletions mothra/__local_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
}
}

USE_CONCURRENCY = False

# Make this unique, and don't share it with anybody.
SECRET_KEY = '*f$)twxl*rdk*o@^j%^0f0r#z7=kkyw=-2v*rjdnon_j==1uw@'

Expand Down
53 changes: 36 additions & 17 deletions mothra/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,23 +123,6 @@
os.path.join(PROJECT_DIR, 'fixtures'),
)

INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.admin',
'south',
'workflows',
'website',
'signuplogin',
'django_extensions',
'django.contrib.humanize',
'orderable_inlines',
)

# A sample logging configuration. The only tangible logging
# performed by this configuration is to send an email to
# the site admins on every HTTP 500 error when DEBUG=False.
Expand Down Expand Up @@ -178,6 +161,42 @@
except ImportError:
pass

if USE_CONCURRENCY:
INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.admin',
'south',
'workflows',
'website',
'signuplogin',
'django_extensions',
'django.contrib.humanize',
'orderable_inlines',
'djcelery',
)
else:
INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.admin',
'south',
'workflows',
'website',
'signuplogin',
'django_extensions',
'django.contrib.humanize',
'orderable_inlines',
)

TEMPLATE_CONTEXT_PROCESSORS = DEFAULT_SETTINGS.TEMPLATE_CONTEXT_PROCESSORS

TEMPLATES_FOLDER = os.path.join(PROJECT_DIR, 'templates')
Expand Down
6 changes: 6 additions & 0 deletions server-requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
-r requirements.txt
celery==2.5.3
redis==2.4.11
django-celery==2.5.5
django-celery-with-redis==2.5

7 changes: 4 additions & 3 deletions workflows/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@
from workflows.thumbs import ThumbnailField

from mothra.settings import DEBUG
from mothra.settings import USE_CONCURRENCY

if not DEBUG:
if USE_CONCURRENCY:
from workflows.tasks import runWidgetAsync, runForLoopIteration

class Connection(models.Model):
Expand Down Expand Up @@ -107,7 +108,7 @@ def run_for_loop(self):
proper_output.save()
fi.finished=True
fi.save()
if DEBUG or 1==1:
if not USE_CONCURRENCY or 1==1:
unfinished_list = self.get_runnable_widgets()
try:
while len(unfinished_list)>0:
Expand Down Expand Up @@ -157,7 +158,7 @@ def run_for_loop(self):
current_iteration = current_iteration+1

def run(self):
if DEBUG or not self.widget:
if not USE_CONCURRENCY or not self.widget:
unfinished_list = self.get_runnable_widgets()
try:
total = self.widgets.count()
Expand Down

0 comments on commit 3c0c144

Please sign in to comment.