
from contextlib import contextmanager

from rq import Connection, Queue

from byceps.redis import redis


@contextmanager
def connection():
    with Connection(redis.client):
        yield


def get_queue(app):
    is_async = app.config['JOBS_ASYNC']
    return Queue(is_async=is_async)


def enqueue(*args, **kwargs):
    """Add the function call to the queue as a job."""
    with connection():
        queue = get_queue()
        queue.enqueue(*args, **kwargs)


from contextlib import contextmanager

from flask import current_app
from rq import Connection, Queue

from byceps.redis import redis


@contextmanager
def connection():
    with Connection(redis.client):
        yield


def get_queue(app):
    is_async = app.config['JOBS_ASYNC']
    return Queue(is_async=is_async)


def enqueue(*args, **kwargs):
    """Add the function call to the queue as a job."""
    with connection():
        queue = get_queue(current_app)
        queue.enqueue(*args, **kwargs)

Fix `get_queue` call in `enqueue`
Fix `get_queue` call in `enqueue`

  
  from contextlib import contextmanager
  
+ from flask import current_app
  from rq import Connection, Queue
  
  from byceps.redis import redis
  
  
  @contextmanager
  def connection():
      with Connection(redis.client):
          yield
  
  
  def get_queue(app):
      is_async = app.config['JOBS_ASYNC']
      return Queue(is_async=is_async)
  
  
  def enqueue(*args, **kwargs):
      """Add the function call to the queue as a job."""
      with connection():
-         queue = get_queue()
+         queue = get_queue(current_app)
          queue.enqueue(*args, **kwargs)
  
Fix `get_queue` call in `enqueue`
## Code Before:

from contextlib import contextmanager

from rq import Connection, Queue

from byceps.redis import redis


@contextmanager
def connection():
    with Connection(redis.client):
        yield


def get_queue(app):
    is_async = app.config['JOBS_ASYNC']
    return Queue(is_async=is_async)


def enqueue(*args, **kwargs):
    """Add the function call to the queue as a job."""
    with connection():
        queue = get_queue()
        queue.enqueue(*args, **kwargs)

## Instruction:
Fix `get_queue` call in `enqueue`
## Code After:

from contextlib import contextmanager

from flask import current_app
from rq import Connection, Queue

from byceps.redis import redis


@contextmanager
def connection():
    with Connection(redis.client):
        yield


def get_queue(app):
    is_async = app.config['JOBS_ASYNC']
    return Queue(is_async=is_async)


def enqueue(*args, **kwargs):
    """Add the function call to the queue as a job."""
    with connection():
        queue = get_queue(current_app)
        queue.enqueue(*args, **kwargs)
