feature: Use multi-thread to compiler pages (#1199)
This commit is contained in:
parent
8947c26c7e
commit
00fc2f24f3
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
import asyncio
|
import asyncio
|
||||||
import inspect
|
import inspect
|
||||||
|
from multiprocessing.pool import ThreadPool
|
||||||
from typing import (
|
from typing import (
|
||||||
Any,
|
Any,
|
||||||
AsyncIterator,
|
AsyncIterator,
|
||||||
@ -454,17 +455,22 @@ class App(Base):
|
|||||||
|
|
||||||
# Compile the pages.
|
# Compile the pages.
|
||||||
custom_components = set()
|
custom_components = set()
|
||||||
|
thread_pool = ThreadPool()
|
||||||
for route, component in self.pages.items():
|
for route, component in self.pages.items():
|
||||||
component.add_style(self.style)
|
component.add_style(self.style)
|
||||||
compiler.compile_page(
|
thread_pool.apply_async(
|
||||||
route,
|
compiler.compile_page,
|
||||||
component,
|
args=(
|
||||||
self.state,
|
route,
|
||||||
self.connect_error_component,
|
component,
|
||||||
|
self.state,
|
||||||
|
self.connect_error_component,
|
||||||
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
# Add the custom components from the page to the set.
|
# Add the custom components from the page to the set.
|
||||||
custom_components |= component.get_custom_components()
|
custom_components |= component.get_custom_components()
|
||||||
|
thread_pool.close()
|
||||||
|
thread_pool.join()
|
||||||
|
|
||||||
# Compile the custom components.
|
# Compile the custom components.
|
||||||
compiler.compile_components(custom_components)
|
compiler.compile_components(custom_components)
|
||||||
|
Loading…
Reference in New Issue
Block a user