[task] Avoid importing the celery libs when task server if off
@@ -502,13 +502,13 @@ class ApiWrapper(object):
self.api = _get_api(request, snippet)
def __getattr__(self, name):
+ if TASK_SERVER.ENABLED.get():
from notebook import tasks as ntasks
- if TASK_SERVER.ENABLED.get() and hasattr(ntasks, name):
+ if hasattr(ntasks, name):
attr = object.__getattribute__(ntasks, name)
def _method(*args, **kwargs):
return attr(*args, **dict(kwargs, postdict=self.request.POST, user_id=self.request.user.id))
return _method
- else:
return object.__getattribute__(self.api, name)
