Skip to content

Fix ASGIMultiprocess args mismatch #2228

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

Merged
merged 1 commit into from
May 21, 2025

Conversation

dolfinus
Copy link
Contributor

Description

I' using FastStream with uvicorn, multiple workers and ASGI endpoint. After upgrading to 0.5.41 I got error:

╭────────────────────────────────────────────────────────────────────── Traceback (most recent call last) ──────────────────────────────────────────────────────────────────────╮
│ /home/maxim/Repo/data-rentgen/.venv/lib/python3.12/site-packages/faststream/cli/main.py:172 in run                                                                            │
│                                                                                                                                                                               │
│   169 │   │   elif isinstance(app_obj, AsgiFastStream):                                                                                                                       │
│   170 │   │   │   from faststream.cli.supervisors.asgi_multiprocess import ASGIMultiprocess                                                                                   │
│   171 │   │   │                                                                                                                                                               │
│ ❱ 172 │   │   │   ASGIMultiprocess(                                                                                                                                           │
│   173 │   │   │   │   target=app,                                                                                                                                             │
│   174 │   │   │   │   args=args,  # type: ignore[arg-type]                                                                                                                    │
│   175 │   │   │   │   workers=workers,                                                                                                                                        │
│                                                                                                                                                                               │
│ ╭───────────────────────────────────────────────────── locals ─────────────────────────────────────────────────────╮                                                          │
│ │              app = 'data_rentgen.consumer:get_application'                                                       │                                                          │
│ │          app_dir = '.'                                                                                           │                                                          │
│ │          app_obj = <faststream.asgi.app.AsgiFastStream object at 0x7d93d977eed0>                                 │                                                          │
│ │             args = ('data_rentgen.consumer:get_application', {'host': '0.0.0.0', 'port': '8001'}, True, None, 0) │                                                          │
│ │ casted_log_level = 0                                                                                             │                                                          │
│ │              ctx = <click.core.Context object at 0x7d93dafc3260>                                                 │                                                          │
│ │            extra = {'host': '0.0.0.0', 'port': '8001'}                                                           │                                                          │
│ │       is_factory = True                                                                                          │                                                          │
│ │       log_config = None                                                                                          │                                                          │
│ │        log_level = <LogLevels.notset: 'notset'>                                                                  │                                                          │
│ │      module_path = PosixPath('/home/maxim/Repo/data-rentgen/data_rentgen/consumer')                              │                                                          │
│ │           reload = False                                                                                         │                                                          │
│ │ watch_extensions = []                                                                                            │                                                          │
│ │          workers = 2                                                                                             │                                                          │
│ ╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯                                                          │
│                                                                                                                                                                               │
│ /home/maxim/Repo/data-rentgen/.venv/lib/python3.12/site-packages/faststream/cli/supervisors/asgi_multiprocess.py:11 in __init__                                               │
│                                                                                                                                                                               │
│    8 │   def __init__(                                                                                                                                                        │
│    9 │   │   self, target: str, args: Tuple[str, Dict[str, str], bool, int], workers: int                                                                                     │
│   10 │   ) -> None:                                                                                                                                                           │
│ ❱ 11 │   │   _, uvicorn_kwargs, is_factory, log_level = args                                                                                                                  │
│   12 │   │   self._target = target                                                                                                                                            │
│   13 │   │   self._uvicorn_kwargs = cast_uvicorn_params(uvicorn_kwargs or {})                                                                                                 │
│   14 │   │   self._workers = workers                                                                                                                                          │
│                                                                                                                                                                               │
│ ╭──────────────────────────────────────────────── locals ─────────────────────────────────────────────────╮                                                                   │
│ │    args = ('data_rentgen.consumer:get_application', {'host': '0.0.0.0', 'port': '8001'}, True, None, 0) │                                                                   │
│ │    self = <faststream.cli.supervisors.asgi_multiprocess.ASGIMultiprocess object at 0x7d93d9f7f320>      │                                                                   │
│ │  target = 'data_rentgen.consumer:get_application'                                                       │                                                                   │
│ │ workers = 2                                                                                             │                                                                   │
│ ╰─────────────────────────────────────────────────────────────────────────────────────────────────────────╯                                                                   │
╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
ValueError: too many values to unpack (expected 4)

#2203 added log_config to function args, but ASGIMultiprocess parses this tuple, and it haven't been upgraded properly.

Type of change

Please delete options that are not relevant.

  • Documentation (typos, code examples, or any documentation updates)
  • Bug fix (a non-breaking change that resolves an issue)
  • New feature (a non-breaking change that adds functionality)
  • Breaking change (a fix or feature that would disrupt existing functionality)
  • This change requires a documentation update

Checklist

  • My code adheres to the style guidelines of this project (scripts/lint.sh shows no errors)
  • I have conducted a self-review of my own code
  • I have made the necessary changes to the documentation
  • My changes do not generate any new warnings
  • I have added tests to validate the effectiveness of my fix or the functionality of my new feature
  • Both new and existing unit tests pass successfully on my local environment by running scripts/test-cov.sh
  • I have ensured that static analysis tests are passing by running scripts/static-analysis.sh
  • I have included code examples to illustrate the modifications

@CLAassistant
Copy link

CLAassistant commented May 21, 2025

CLA assistant check
All committers have signed the CLA.

@dolfinus dolfinus force-pushed the bugfix/asgi-multiprocess-args branch from 8307880 to 8fdbd4c Compare May 21, 2025 12:15
@dolfinus dolfinus force-pushed the bugfix/asgi-multiprocess-args branch from 8fdbd4c to 9196f03 Compare May 21, 2025 12:17
@Lancetnik Lancetnik added this pull request to the merge queue May 21, 2025
Merged via the queue into ag2ai:main with commit b2ea7cd May 21, 2025
33 checks passed
@dolfinus dolfinus deleted the bugfix/asgi-multiprocess-args branch June 9, 2025 12:42
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

Successfully merging this pull request may close these issues.

3 participants