Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Process multiple run requests #724

Open
devaxolotl opened this issue Apr 26, 2024 · 2 comments
Open

Process multiple run requests #724

devaxolotl opened this issue Apr 26, 2024 · 2 comments

Comments

@devaxolotl
Copy link

I'm trying to set up kotlin-compiler-server but have run into something I don't know how to get past.

I am able to run the server but it looks like it will only process one request at a time. If I send a request that takes 10 seconds and then send another request the second request only starts after the first request completes.

Is this the expected behavior? Is it possible to get it to process multiple requests at the same time?

@nikpachoo
Copy link
Collaborator

Hi @devaxolotl!
I checked it locally and couldn't reproduce the issue. A couple of requests were completed simultaneously.
Please share more details if the problem remains so we can reproduce your case.

@devaxolotl
Copy link
Author

Thank you for the reply @nikpachoo, here are more details on what I am trying:

  1. Cloned the repo
  2. Built the Docker image using ./docker-image-build.sh
  3. Ran it in a docker container using
docker run -d -p 8080:8080 --name kotlin-compiler-server [id of image]
  1. At this point I am able to access the REST endpoints
  2. Using the endpoint /api/compiler/run I set up two REST clients
  3. In one client I set up this call
POST http://localhost:8080/api/compiler/run
Content-Type: application/json

{
    "args": "1 2 3",
    "files": [
        {
            "name": "File.kt",
            "text": "fun main() {\n    Thread.sleep(5000L)\n\n    println(\"5 seconds has passed\")\n}"
        }
    ]
}

In another client I set up this call:

POST http://localhost:8080/api/compiler/run
Content-Type: application/json

{
    "args": "1 2 3",
    "files": [
        {
            "name": "File.kt",
            "text": "fun main() {\n    println(\"second call\")\n}"
        }
    ]
}
  1. Now I run the first call that sleeps then immediately run the second call after that. The second call seems to only return after the first one returns or times out.

I also tried it with a long running call instead of using sleep or timers.

fun main() {
    val n = 45
    println("Fibonacci $n numbers:")
    for (i in 0 until n) {
        print(fibonacci(i).toString() + ", ")
    }
}

fun fibonacci(n: Int): Int {
    return if (n <= 1) {
        n
    } else {
        fibonacci(n - 1) + fibonacci(n - 2)
    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants