prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  Bad Semaphore initialization in RequestLimiter
  **Describe the bug**
  RequestLimiter takes a number as parameter and use it to set up a Semaphore. The issue is that the environment variable indicates the concurrent allowed requests per worker. When the semaphore is created (https://github.com/deepset-ai/haystack/blob/6790eaf7d8be05c5674d97a75cc5783e00a66875/rest_api/rest_api/controller/utils.py#L13), this value is set down by 1. This is clearly not what the project tried to achieve (at least per naming). 
  
  **Error message**
  REST API will always return it's busy, error 503 when CONCURRENT_REQUEST_PER_WORKER is equal to CONCURRENT_REQUEST_PER_WORKER -1. When user set the concurrency to 1, it will never be able to call the API, since the Semaphore declaration will be Semaphore(0)
  
  **Expected behavior**
  Being able to set the request limits using the env variable CONCURRENT_REQUEST_PER_WORKER
  
  **Additional context**
  
  
  **To Reproduce**
  
  
  **FAQ Check**
  - [x] Have you had a look at [our new FAQ page](https://haystack.deepset.ai/overview/faq)?
  
  **System:**
   - OS: Ubuntu
   - GPU/CPU: i7/ Nvidia
   - Haystack version (commit or version number): 1.9
   - DocumentStore:
   - Reader:
   - Retriever:
  
  
  </issue>
  <code>
  [start of rest_api/rest_api/controller/utils.py]
  1 from typing import Type, NewType
  2 
  3 import inspect
  4 from contextlib import contextmanager
  5 from threading import Semaphore
  6 
  7 from fastapi import Form, HTTPException
  8 from pydantic import BaseModel
  9 
  10 
  11 class RequestLimiter:
  12     def __init__(self, limit):
  13         self.semaphore = Semaphore(limit - 1)
  14 
  15     @contextmanager
  16     def run(self):
  17         acquired = self.semaphore.acquire(blocking=False)
  18         if not acquired:
  19             raise HTTPException(status_code=503, detail="The server is busy processing requests.")
  20         try:
  21             yield acquired
  22         finally:
  23             self.semaphore.release()
  24 
  25 
  26 StringId = NewType("StringId", str)
  27 
  28 
  29 def as_form(cls: Type[BaseModel]):
  30     """
  31     Adds an as_form class method to decorated models. The as_form class method
  32     can be used with FastAPI endpoints
  33     """
  34     new_params = [
  35         inspect.Parameter(
  36             field.alias,
  37             inspect.Parameter.POSITIONAL_ONLY,
  38             default=(Form(field.default) if not field.required else Form(...)),
  39         )
  40         for field in cls.__fields__.values()
  41     ]
  42 
  43     async def _as_form(**data):
  44         return cls(**data)
  45 
  46     sig = inspect.signature(_as_form)
  47     sig = sig.replace(parameters=new_params)
  48     _as_form.__signature__ = sig  # type: ignore
  49     setattr(cls, "as_form", _as_form)
  50     return cls
  51
  [end of rest_api/rest_api/controller/utils.py]
  </code>
  
  I need you to solve this issue by generating a single patch file that I can apply directly to this repository using git apply. Please respond with a single patch file in the following format.
  <patch>
  diff --git a/file.py b/file.py
  --- a/file.py
  +++ b/file.py
  @@ -1,27 +1,35 @@
   def euclidean(a, b):
  -    while b:
  -        a, b = b, a % b
  -    return a
  +    if b == 0:
  +        return a
  +    return euclidean(b, a % b)
   
   
   def bresenham(x0, y0, x1, y1):
       points = []
       dx = abs(x1 - x0)
       dy = abs(y1 - y0)
  -    sx = 1 if x0 < x1 else -1
  -    sy = 1 if y0 < y1 else -1
  -    err = dx - dy
  +    x, y = x0, y0
  +    sx = -1 if x0 > x1 else 1
  +    sy = -1 if y0 > y1 else 1
   
  -    while True:
  -        points.append((x0, y0))
  -        if x0 == x1 and y0 == y1:
  -            break
  -        e2 = 2 * err
  -        if e2 > -dy:
  -            err -= dy
  -            x0 += sx
  -        if e2 < dx:
  -            err += dx
  -            y0 += sy
  +    if dx > dy:
  +        err = dx / 2.0
  +        while x != x1:
  +            points.append((x, y))
  +            err -= dy
  +            if err < 0:
  +                y += sy
  +                err += dx
  +            x += sx
  +    else:
  +        err = dy / 2.0
  +        while y != y1:
  +            points.append((x, y))
  +            err -= dx
  +            if err < 0:
  +                x += sx
  +                err += dy
  +            y += sy
  +
  +    points.append((x, y))
       return points
  
  </patch>
golden_diff: diff --git a/rest_api/rest_api/controller/utils.py b/rest_api/rest_api/controller/utils.py
  --- a/rest_api/rest_api/controller/utils.py
  +++ b/rest_api/rest_api/controller/utils.py
  @@ -10,7 +10,7 @@
   
   class RequestLimiter:
       def __init__(self, limit):
  -        self.semaphore = Semaphore(limit - 1)
  +        self.semaphore = Semaphore(limit)
   
       @contextmanager
       def run(self):
  
verification_info: {"golden_diff": "diff --git a/rest_api/rest_api/controller/utils.py b/rest_api/rest_api/controller/utils.py\n--- a/rest_api/rest_api/controller/utils.py\n+++ b/rest_api/rest_api/controller/utils.py\n@@ -10,7 +10,7 @@\n \n class RequestLimiter:\n     def __init__(self, limit):\n-        self.semaphore = Semaphore(limit - 1)\n+        self.semaphore = Semaphore(limit)\n \n     @contextmanager\n     def run(self):\n", "issue": "Bad Semaphore initialization in RequestLimiter\n**Describe the bug**\r\nRequestLimiter takes a number as parameter and use it to set up a Semaphore. The issue is that the environment variable indicates the concurrent allowed requests per worker. When the semaphore is created (https://github.com/deepset-ai/haystack/blob/6790eaf7d8be05c5674d97a75cc5783e00a66875/rest_api/rest_api/controller/utils.py#L13), this value is set down by 1. This is clearly not what the project tried to achieve (at least per naming). \r\n\r\n**Error message**\r\nREST API will always return it's busy, error 503 when CONCURRENT_REQUEST_PER_WORKER is equal to CONCURRENT_REQUEST_PER_WORKER -1. When user set the concurrency to 1, it will never be able to call the API, since the Semaphore declaration will be Semaphore(0)\r\n\r\n**Expected behavior**\r\nBeing able to set the request limits using the env variable CONCURRENT_REQUEST_PER_WORKER\r\n\r\n**Additional context**\r\n\r\n\r\n**To Reproduce**\r\n\r\n\r\n**FAQ Check**\r\n- [x] Have you had a look at [our new FAQ page](https://haystack.deepset.ai/overview/faq)?\r\n\r\n**System:**\r\n - OS: Ubuntu\r\n - GPU/CPU: i7/ Nvidia\r\n - Haystack version (commit or version number): 1.9\r\n - DocumentStore:\r\n - Reader:\r\n - Retriever:\r\n\n", "before_files": [{"content": "from typing import Type, NewType\n\nimport inspect\nfrom contextlib import contextmanager\nfrom threading import Semaphore\n\nfrom fastapi import Form, HTTPException\nfrom pydantic import BaseModel\n\n\nclass RequestLimiter:\n    def __init__(self, limit):\n        self.semaphore = Semaphore(limit - 1)\n\n    @contextmanager\n    def run(self):\n        acquired = self.semaphore.acquire(blocking=False)\n        if not acquired:\n            raise HTTPException(status_code=503, detail=\"The server is busy processing requests.\")\n        try:\n            yield acquired\n        finally:\n            self.semaphore.release()\n\n\nStringId = NewType(\"StringId\", str)\n\n\ndef as_form(cls: Type[BaseModel]):\n    \"\"\"\n    Adds an as_form class method to decorated models. The as_form class method\n    can be used with FastAPI endpoints\n    \"\"\"\n    new_params = [\n        inspect.Parameter(\n            field.alias,\n            inspect.Parameter.POSITIONAL_ONLY,\n            default=(Form(field.default) if not field.required else Form(...)),\n        )\n        for field in cls.__fields__.values()\n    ]\n\n    async def _as_form(**data):\n        return cls(**data)\n\n    sig = inspect.signature(_as_form)\n    sig = sig.replace(parameters=new_params)\n    _as_form.__signature__ = sig  # type: ignore\n    setattr(cls, \"as_form\", _as_form)\n    return cls\n", "path": "rest_api/rest_api/controller/utils.py"}]}