def test_reduce(self): try: from celery.backends.redis import RedisBackend x = RedisBackend(app=self.app, new_join=True) self.assertTrue(loads(dumps(x))) except ImportError: raise SkipTest('redis not installed')
def get_redis_or_SkipTest(): def emit_no_redis_msg(reason): global _no_redis_msg_emitted if not _no_redis_msg_emitted: sys.stderr.write("\n" + _no_redis_msg % reason + "\n") _no_redis_msg_emitted = True if redis.redis is None: emit_no_redis_msg("not installed") raise SkipTest("redis library not installed") try: tb = RedisBackend(redis_db="celery_unittest") try: # Evaluate lazy connection tb.client.info() except ConnectionError, exc: emit_no_redis_msg("not running") raise SkipTest("can't connect to redis: %s" % (exc, )) return tb
def test_reduce(self): from celery.backends.redis import RedisBackend x = RedisBackend(app=self.app) assert loads(dumps(x))
def test_reduce(self): pytest.importorskip('redis') from celery.backends.redis import RedisBackend x = RedisBackend(app=self.app) assert loads(dumps(x))
# Minifying HTML codes htmlminify = HTMLMIN() # Cross site request forgery protection to prevent any request coming to the site from others csrf = CSRFProtect() # The session manager session = Session() # Compressor for all types of data [xml, zip, js, css] compress = Compress() # Principal for organizing the authorization and the user information inside the app principal = Principal() # Two main roles for my users admin_permission = Permission(RoleNeed('admin')) user_permission = Permission(RoleNeed('user')) # Sending emails to the cloud mail = Mail() # Run tasks with celery celery = Celery() celery.backend = RedisBackend(app=celery) # Function to load the logged user id into flask_login then to save it as an "current_user" object @login_manager.user_loader def load_user(userid): return User.query.get(userid)
def backend(redis_url): backend = RedisBackend(redis_url) try: yield backend finally: clear_locks(backend)