Skip to content
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

Need timeout control for WorkerManager #2603

Closed
1 task done
selaselah opened this issue Nov 17, 2022 · 3 comments
Closed
1 task done

Need timeout control for WorkerManager #2603

selaselah opened this issue Nov 17, 2022 · 3 comments

Comments

@selaselah
Copy link

Is there an existing issue for this?

  • I have searched the existing issues

Is your feature request related to a problem? Please describe.

OS: mac
sanic-version: 22.9.1

when i start a server without single_thread and set workers>=1, the server crash

[sanic.error 2022-11-17 17:16:10,932] [pid 5311] [ERROR]: Experienced exception while trying to serve  [in /Users/chendx/anaconda3-2022.05/envs/pigai/lib/python3.9/site-packages/sanic/mixins/startup.py:854]
Traceback (most recent call last):
  File "/Users/chendx/anaconda3-2022.05/envs/pigai/lib/python3.9/site-packages/sanic/mixins/startup.py", line 851, in serve
    manager.run()
  File "/Users/chendx/anaconda3-2022.05/envs/pigai/lib/python3.9/site-packages/sanic/worker/manager.py", line 63, in run
    self.monitor()
  File "/Users/chendx/anaconda3-2022.05/envs/pigai/lib/python3.9/site-packages/sanic/worker/manager.py", line 99, in monitor
    self.wait_for_ack()
  File "/Users/chendx/anaconda3-2022.05/envs/pigai/lib/python3.9/site-packages/sanic/worker/manager.py", line 139, in wait_for_ack
    sys.exit(1)
SystemExit: 1

new server sanic intro a WorkerManager.
the manager will wait subprocess to ready in 5 seconds (WorkerManager.THRESHOLD = 500)
but subprocess has lots of resource to load (jieba custom data, torch model etc.)
preload on main processing not working (maybe caused by macos's fork method)

Describe the solution you'd like

need a params to control the WorkerManager's wait timeout.

Additional context

No response

@Tronic
Copy link
Member

Tronic commented Nov 17, 2022

As a workaround, does it help if you load your data in @app.after_server_start listener?

@ahopkins
Copy link
Member

ahopkins commented Nov 17, 2022

That seems reasonable, but you also can monkeypatch it pretty easy if needed. That was why I made it a class variable. Sometimes making things this this an app.config is difficult since there are so many ways to control them and users get frustrated when things do not work because they updated the config after the variable was used.

@ahopkins
Copy link
Member

Should be resolved by #2610

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants