Skip to content

Commit c42ea42

Browse files
committed
Updated package v4.13
1 parent 2f33948 commit c42ea42

File tree

3 files changed

+49
-17
lines changed

3 files changed

+49
-17
lines changed

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,15 @@
22

33
All notable changes to LocalLab will be documented in this file.
44

5+
## 0.4.13 - 2025-03-11
6+
7+
### Fixed
8+
9+
- Fixed critical error with LifespanOn initialization: "LifespanOn.**init**() got an unexpected keyword argument 'logger'"
10+
- Improved compatibility with different versions of uvicorn by properly handling lifespan initialization
11+
- Enhanced error handling for different lifespan implementations
12+
- Added graceful fallbacks when lifespan initialization fails
13+
514
## 0.4.12 - 2025-03-11
615

716
### Fixed

locallab/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
LocalLab - A lightweight AI inference server for running LLMs locally
33
"""
44

5-
__version__ = "0.4.12"
5+
__version__ = "0.4.13"
66

77
# Only import what's necessary initially, lazy-load the rest
88
from .logger import get_logger

locallab/server.py

Lines changed: 39 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -209,43 +209,66 @@ async def serve(self, sockets=None):
209209
try:
210210
# Try the newer location first (uvicorn >= 0.18.0)
211211
from uvicorn.lifespan.on import LifespanOn
212+
# LifespanOn doesn't accept logger parameter
212213
self.lifespan = LifespanOn(
213214
self.config.app,
214-
self.config.lifespan_on if hasattr(self.config, "lifespan_on") else "auto",
215-
logger=logger
215+
self.config.lifespan_on if hasattr(self.config, "lifespan_on") else "auto"
216216
)
217217
logger.info("Using LifespanOn from uvicorn.lifespan.on")
218218
except (ImportError, AttributeError) as e:
219219
logger.debug(f"Failed to import LifespanOn: {str(e)}")
220220
try:
221221
# Try the older location (uvicorn < 0.18.0)
222222
from uvicorn.lifespan.lifespan import Lifespan
223-
self.lifespan = Lifespan(
224-
self.config.app,
225-
"auto",
226-
logger=logger
227-
)
223+
try:
224+
# Try with logger parameter first
225+
self.lifespan = Lifespan(
226+
self.config.app,
227+
"auto",
228+
logger
229+
)
230+
except TypeError:
231+
# If that fails, try without logger parameter
232+
self.lifespan = Lifespan(
233+
self.config.app,
234+
"auto"
235+
)
228236
logger.info("Using Lifespan from uvicorn.lifespan.lifespan")
229237
except (ImportError, AttributeError) as e:
230238
logger.debug(f"Failed to import Lifespan from lifespan.lifespan: {str(e)}")
231239
try:
232240
# Try the oldest location
233241
from uvicorn.lifespan import Lifespan
234-
self.lifespan = Lifespan(
235-
self.config.app,
236-
"auto",
237-
logger=logger
238-
)
242+
try:
243+
# Try with logger parameter first
244+
self.lifespan = Lifespan(
245+
self.config.app,
246+
"auto",
247+
logger
248+
)
249+
except TypeError:
250+
# If that fails, try without logger parameter
251+
self.lifespan = Lifespan(
252+
self.config.app,
253+
"auto"
254+
)
239255
logger.info("Using Lifespan from uvicorn.lifespan")
240256
except (ImportError, AttributeError) as e:
241257
logger.debug(f"Failed to import Lifespan from uvicorn.lifespan: {str(e)}")
242258
try:
243259
# Try the newest location (uvicorn >= 0.21.0)
244260
from uvicorn.lifespan.state import LifespanState
245-
self.lifespan = LifespanState(
246-
self.config.app,
247-
logger=logger
248-
)
261+
try:
262+
# Try with logger parameter first
263+
self.lifespan = LifespanState(
264+
self.config.app,
265+
logger=logger
266+
)
267+
except TypeError:
268+
# If that fails, try without logger parameter
269+
self.lifespan = LifespanState(
270+
self.config.app
271+
)
249272
logger.info("Using LifespanState from uvicorn.lifespan.state")
250273
except (ImportError, AttributeError) as e:
251274
logger.debug(f"Failed to import LifespanState: {str(e)}")

0 commit comments

Comments
 (0)