Skip to content
This repository was archived by the owner on Jun 6, 2024. It is now read-only.

added the method for call ExecutorService.shutdownNow.#331

Open
Miura-KR wants to merge 2 commits into
TheoKanning:mainfrom
Miura-KR:main
Open

added the method for call ExecutorService.shutdownNow.#331
Miura-KR wants to merge 2 commits into
TheoKanning:mainfrom
Miura-KR:main

Conversation

@Miura-KR

@Miura-KR Miura-KR commented Jul 6, 2023

Copy link
Copy Markdown

I want to interrupt streaming response, so I added the method on OpenAiService for call ExecutorService.shutdownNow.

@cryptoapebot

Copy link
Copy Markdown

Question though, doesn't shutting the ExecutorService shut down all threads? It's functionally equivalent to just quitting the program as anything w/ a thread will be shut down.

@Miura-KR

Miura-KR commented Jul 6, 2023

Copy link
Copy Markdown
Author

The shutdown methods don't quit your program.
They only affect the threads that are managed by the specific ExecutorService instance you're calling shutdown on. If you have other threads or ExecutorServices running in your program that you haven't shut down, those will continue running.

@cryptoapebot

Copy link
Copy Markdown

I understand that--that's why I said equivalent to, but my comment was it seems like a heavyweight way just to interrupt a single stream. Won't you have to restart the/a new ExecutorService to initiate new streams?

@Miura-KR

Miura-KR commented Jul 6, 2023

Copy link
Copy Markdown
Author

You're correct.
This library already uses ExcecutorService.shutdown to terminate streaming threads, so I added this method.
https://github.com/TheoKanning/openai-java#streaming-thread-shutdown )
If you know of any other good ways to do this, I would appreciate it.

@cryptoapebot

Copy link
Copy Markdown

Seems like the best and only way for now.....

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants