Example #1
0
    settings, 'ACTIVITYLOG_MODE', 'sync',
)
ACTIVITYLOG_TASK_EXPIRATION = getattr(
    settings, 'ACTIVITYLOG_TASK_EXPIRATION', 30,
)
if ACTIVITYLOG_MODE == 'sync':
    def maybe_async(function):
        result = OptionBag()
        result.delay = function
        return result
    serial_execution = False
elif ACTIVITYLOG_MODE == 'rq':
    from django_rq import job
    maybe_async = job(
        'activitylog',
        timeout=ACTIVITYLOG_TASK_EXPIRATION,
        result_ttl=ACTIVITYLOG_TASK_EXPIRATION,
    )
    serial_execution = True
elif ACTIVITYLOG_MODE == 'celery':
    import celery
    maybe_async = celery.task(
        expires=ACTIVITYLOG_TASK_EXPIRATION,
    )
    serial_execution = True


@maybe_async
@transaction.commit_on_success
def update_activity(user_id, address, agent, _now_dt):
    ip, _ = IP.concurrent_get_or_create(
Example #2
0

# Stub class to preserve backwards compatibility and issue a warning
class Async(Celery):
    def __init__(self, *args, **kwargs):
        message = '{path}.Async is deprecated. Use {path}.Celery instead.'
        warnings.warn(message.format(path=__name__), DeprecationWarning)
        super(Async, self).__init__(*args, **kwargs)


try:
    from django_rq import job
except ImportError:
    pass
else:
    _rq_job = job('default', result_ttl=0)(_generate_file)


class RQ(BaseAsync):
    """
    A backend that uses RQ to generate the images.
    """
    def __init__(self, *args, **kwargs):
        try:
            import django_rq  # noqa
        except ImportError:
            raise ImproperlyConfigured('You must install django-rq to use'
                                       ' imagekit.cachefiles.backends.RQ.')
        super(RQ, self).__init__(*args, **kwargs)

    def schedule_generation(self, file, force=False):
Example #3
0
            "password": settings.GITHUB_TOKEN,
            "email": "*****@*****.**",
            "username": "******",
        })
        ctx.keychain.set_service("github", github_app, True)

        steps = [
            step.to_spec(project_config=ctx.project_config,
                         skip=step.path in skip_tasks)
            for step in plan.steps.all()
        ]
        org = ctx.keychain.get_org(current_org)
        result.run(ctx, plan, steps, org)


run_flows_job = job(run_flows)


def enqueuer():
    logger.debug("Enqueuer live", extra={"tag": "jobs.enqueuer"})
    for j in Job.objects.filter(enqueued_at=None):
        j.invalidate_related_preflight()
        rq_job = run_flows_job.delay(
            user=j.user,
            plan=j.plan,
            skip_tasks=j.skip_tasks(),
            organization_url=j.organization_url,
            result_class=Job,
            result_id=j.id,
        )
        j.job_id = rq_job.id
Example #4
0
                repo_id=repo_id,
                repo_branch=commit_ish,
                project_path=repo_root,
                originating_user_id=originating_user_id,
            )
    except Exception as e:
        scratch_org.finalize_provision(error=e,
                                       originating_user_id=originating_user_id)
        tb = traceback.format_exc()
        logger.error(tb)
        raise
    else:
        scratch_org.finalize_provision(originating_user_id=originating_user_id)


create_branches_on_github_then_create_scratch_org_job = job(
    create_branches_on_github_then_create_scratch_org)


def convert_to_dev_org(scratch_org, *, task, originating_user_id=None):
    """
    Convert an Epic playground org into a Task Dev org
    """
    try:
        task.refresh_from_db()
        scratch_org.refresh_from_db()
        _create_branches_on_github(
            user=scratch_org.owner,
            repo_id=task.get_repo_id(),
            epic=task.epic,
            task=task,
            task_sha=scratch_org.latest_commit,
Example #5
0

# Stub class to preserve backwards compatibility and issue a warning
class Async(Celery):
    def __init__(self, *args, **kwargs):
        message = '{path}.Async is deprecated. Use {path}.Celery instead.'
        warnings.warn(message.format(path=__name__), DeprecationWarning)
        super(Async, self).__init__(*args, **kwargs)


try:
    from django_rq import job
except ImportError:
    pass
else:
    _rq_job = job('default', result_ttl=0)(_generate_file)


class RQ(BaseAsync):
    """
    A backend that uses RQ to generate the images.
    """
    def __init__(self, *args, **kwargs):
        try:
            import django_rq  # noqa
        except ImportError:
            raise ImproperlyConfigured('You must install django-rq to use'
                                       ' imagekit.cachefiles.backends.RQ.')
        super(RQ, self).__init__(*args, **kwargs)

    def schedule_generation(self, file, force=False):
Example #6
0
    'ACTIVITYLOG_TASK_EXPIRATION',
    30,
)
if ACTIVITYLOG_MODE == 'sync':

    def maybe_async(function):
        result = OptionBag()
        result.delay = function
        return result

    serial_execution = False
elif ACTIVITYLOG_MODE == 'rq':
    from django_rq import job
    maybe_async = job(
        'activitylog',
        timeout=ACTIVITYLOG_TASK_EXPIRATION,
        result_ttl=ACTIVITYLOG_TASK_EXPIRATION,
    )
    serial_execution = True
elif ACTIVITYLOG_MODE == 'celery':
    import celery
    maybe_async = celery.task(expires=ACTIVITYLOG_TASK_EXPIRATION, )
    serial_execution = True


@maybe_async
@transaction.commit_on_success
def update_activity(user_id, address, agent, _now_dt):
    ip, _ = IP.concurrent_get_or_create(
        address=address,
        fast_mode=serial_execution,