mirror of
https://github.com/gradio-app/gradio.git
synced 2025-01-30 11:00:11 +08:00
[Refactoring] Convert async functions that don't contain await
statements to normal functions (#5677)
* [Refactoring] Convert async functions that don't contain `await` statements to normal functions * add changeset * add changeset * fix tests --------- Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com> Co-authored-by: Abubakar Abid <abubakar@huggingface.co>
This commit is contained in:
parent
c5e9695596
commit
9f9af327c9
5
.changeset/famous-comics-fly.md
Normal file
5
.changeset/famous-comics-fly.md
Normal file
@ -0,0 +1,5 @@
|
||||
---
|
||||
"gradio": patch
|
||||
---
|
||||
|
||||
feat:[Refactoring] Convert async functions that don't contain `await` statements to normal functions
|
@ -1553,7 +1553,7 @@ Received outputs:
|
||||
"average_duration": block_fn.total_runtime / block_fn.total_runs,
|
||||
}
|
||||
|
||||
async def create_limiter(self):
|
||||
def create_limiter(self):
|
||||
self.limiter = (
|
||||
None
|
||||
if self.max_threads == 40
|
||||
@ -2344,10 +2344,10 @@ Received outputs:
|
||||
"""Events that should be run when the app containing this block starts up."""
|
||||
|
||||
if self.enable_queue:
|
||||
utils.run_coro_in_background(self._queue.start, self.ssl_verify)
|
||||
self._queue.start()
|
||||
# So that processing can resume in case the queue was stopped
|
||||
self._queue.stopped = False
|
||||
utils.run_coro_in_background(self.create_limiter)
|
||||
self.create_limiter()
|
||||
|
||||
def queue_enabled_for_fn(self, fn_index: int):
|
||||
if self.dependencies[fn_index]["queue"] is None:
|
||||
|
@ -76,7 +76,7 @@ class Queue:
|
||||
self.blocks_dependencies = blocks_dependencies
|
||||
self.continuous_tasks: list[Event] = []
|
||||
|
||||
async def start(self, ssl_verify=True):
|
||||
def start(self):
|
||||
run_coro_in_background(self.start_processing)
|
||||
run_coro_in_background(self.start_log_and_progress_updates)
|
||||
if not self.live_updates:
|
||||
|
@ -36,15 +36,13 @@ def mock_event() -> Event:
|
||||
|
||||
|
||||
class TestQueueMethods:
|
||||
@pytest.mark.asyncio
|
||||
async def test_start(self, queue: Queue):
|
||||
await queue.start()
|
||||
def test_start(self, queue: Queue):
|
||||
queue.start()
|
||||
assert queue.stopped is False
|
||||
assert queue.get_active_worker_count() == 0
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_stop_resume(self, queue: Queue):
|
||||
await queue.start()
|
||||
def test_stop_resume(self, queue: Queue):
|
||||
queue.start()
|
||||
queue.close()
|
||||
assert queue.stopped
|
||||
queue.resume()
|
||||
|
Loading…
Reference in New Issue
Block a user