June 19.6.0 Release

All,

I’m planning to do the 19.06.0 release on Sunday 2019/06/16 US Central time. Please let me know if you have issues you want to see resolved before that release and a brief justification. We’ve made a lot of progress on getting organized in the last 8 months, but it’s probably time to push towards noting focus issues that we can/should prioritize.

Thanks!
-S

1 Like

I’ll try and push this week to finish #1475 ASGI.

1 Like

@sjsadowski and @yunstanford, #1475 is done. Take a look please and key me know if we can merge.

Are we waiting for anything else before release?

Great!.

Can we just replace sanic worker with unvicorn worker and run ASGI with Gunicorn ?
gunicorn -w 4 -k uvicorn.workers.UvicornWorker

The ASGI app seems would’t use sanic’s request_class? How to use my own request_class in ASGI app?

Yup.

$ uvicorn server:app                                                                                                   
INFO: Started server process [18313]
INFO: Waiting for application startup.
INFO: Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit)
^CINFO: Shutting down
INFO: Waiting for application shutdown.
INFO: Finished server process [18313]

$  gunicorn -w 4 -k uvicorn.workers.UvicornWorker server:app
[2019-06-24 14:44:25 +0300] [18349] [INFO] Starting gunicorn 19.9.0
[2019-06-24 14:44:25 +0300] [18349] [INFO] Listening at: http://127.0.0.1:8000 (18349)
[2019-06-24 14:44:25 +0300] [18349] [INFO] Using worker: uvicorn.workers.UvicornWorker
[2019-06-24 14:44:25 +0300] [18352] [INFO] Booting worker with pid: 18352
[2019-06-24 14:44:25 +0300] [18353] [INFO] Booting worker with pid: 18353
[2019-06-24 14:44:25 +0300] [18354] [INFO] Booting worker with pid: 18354
[2019-06-24 14:44:25 +0300] [18355] [INFO] Booting worker with pid: 18355
[2019-06-24 14:44:25 +0300] [18352] [INFO] Started server process [18352]
[2019-06-24 14:44:25 +0300] [18352] [INFO] Waiting for application startup.
[2019-06-24 14:44:25 +0300] [18353] [INFO] Started server process [18353]
[2019-06-24 14:44:25 +0300] [18353] [INFO] Waiting for application startup.
[2019-06-24 14:44:25 +0300] [18354] [INFO] Started server process [18354]
[2019-06-24 14:44:25 +0300] [18354] [INFO] Waiting for application startup.
[2019-06-24 14:44:25 +0300] [18355] [INFO] Started server process [18355]
[2019-06-24 14:44:25 +0300] [18355] [INFO] Waiting for application startup.
^C[2019-06-24 14:44:26 +0300] [18349] [INFO] Handling signal: int
[2019-06-24 14:44:27 +0300] [18354] [INFO] Shutting down
[2019-06-24 14:44:27 +0300] [18355] [INFO] Shutting down
[2019-06-24 14:44:27 +0300] [18352] [INFO] Shutting down
[2019-06-24 14:44:27 +0300] [18353] [INFO] Shutting down
[2019-06-24 14:44:27 +0300] [18354] [INFO] Waiting for application shutdown.
[2019-06-24 14:44:27 +0300] [18354] [INFO] Finished server process [18354]
[2019-06-24 14:44:27 +0300] [18354] [INFO] Worker exiting (pid: 18354)
[2019-06-24 14:44:27 +0300] [18355] [INFO] Waiting for application shutdown.
[2019-06-24 14:44:27 +0300] [18355] [INFO] Finished server process [18355]
[2019-06-24 14:44:27 +0300] [18355] [INFO] Worker exiting (pid: 18355)
[2019-06-24 14:44:27 +0300] [18352] [INFO] Waiting for application shutdown.
[2019-06-24 14:44:27 +0300] [18352] [INFO] Finished server process [18352]
[2019-06-24 14:44:27 +0300] [18352] [INFO] Worker exiting (pid: 18352)
[2019-06-24 14:44:27 +0300] [18353] [INFO] Waiting for application shutdown.
[2019-06-24 14:44:27 +0300] [18353] [INFO] Finished server process [18353]
[2019-06-24 14:44:27 +0300] [18353] [INFO] Worker exiting (pid: 18353)
[2019-06-24 14:44:27 +0300] [18349] [INFO] Shutting down: Master

Are you taking about sanic.request.Request? Yes, this class is still used in ASGI mode.

Can you give me an example of what you are trying to achieve? I am not understanding the question.

from sanic import Sanic
from sanic.request import Request
from sanic.response import json

class MyRequest(Request):
    @property
    def single_args(self):
        """只取第一个值作为值"""
        return {k: v[0] for k, v in self.args.items()}

app = Sanic(__name__, log_config={}, request_class=MyRequest)

@app.route("/")
async def index(request):
    print(request.single_args)
    return json({"data": "hello"})

I create a sanic app by passing request_class=MyRequest(which achieves request.user , request.single_args etc.), but in ASGI mode, it doesn’t work, and I get a simple exception says:

ERROR: 'Request' object has no attribute 'single_args'
Traceback (most recent call last):
  File "/Users/zinklu/myproject/sanic/lib/python3.7/site-packages/sanic/app.py", line 942, in handle_request
    response = await response
  File "./cat_and_dog/__init__.py", line 95, in wait_a_minute
    print(request.single_args)
AttributeError: 'Request' object has no attribute 'single_args'

I found this in asgi.py. It always make sanic.request.Request as app’s request. shoud we change Request into sanic_app.request_class?

BTW, I’m not the native english speaker, sorry for the ambiguous expression.

1 Like
  1. No need to apologize to me. That’s what I thought you were asking.
  2. Yes, I think you are correct. That change should be made.

See PR 1614.

awesome!
:grinning::grinning::grinning: