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

Signals Integration #2160

Merged
merged 39 commits into from
Aug 5, 2021
Merged
Show file tree
Hide file tree
Changes from 33 commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
3f9a943
Update some tests
ahopkins May 12, 2021
4124c4e
Update some tests
ahopkins May 30, 2021
2dfc22b
Resolve #2122 route decorator returning tuple
ahopkins May 30, 2021
54df207
Merge branch 'main' into v2routing
ahopkins May 30, 2021
f447193
Use rc sanic-routing version
ahopkins May 31, 2021
e1e61e3
Merge branch 'v2routing' of github.com:sanic-org/sanic into v2routing
ahopkins May 31, 2021
0677286
Update unit tests to <:str>
ahopkins May 31, 2021
ae38342
Merge branch 'main' into v2routing
ahopkins Jun 1, 2021
df10b9f
Minimal working version with some signals implemented
ahopkins Jun 13, 2021
eb4331a
Add more http signals
ahopkins Jun 13, 2021
ee1cd91
squash
ahopkins Jun 13, 2021
5261266
squash
ahopkins Jun 13, 2021
31e9614
squash
ahopkins Jun 13, 2021
e2abdbd
squash
ahopkins Jun 13, 2021
d656a04
Update ASGI and change listeners to signals
ahopkins Jun 14, 2021
1bde6cd
Allow for dynamic ODE signals
ahopkins Jun 14, 2021
1259875
Allow signals to be stacked
ahopkins Jun 14, 2021
c2a032b
Begin tests
ahopkins Jun 15, 2021
38ce65a
Prioritize match_info on keyword argument injection
ahopkins Jun 16, 2021
30c6bc5
Add transformer
ahopkins Jun 20, 2021
ad97ca6
Resolve merge conflict
ahopkins Jun 20, 2021
babb229
WIP on tests
ahopkins Jun 20, 2021
7b6c586
WIP
ahopkins Jun 20, 2021
8c90da0
Compat with signals
ahopkins Jun 20, 2021
1afc6b0
Merge from main and resolve condlicts
ahopkins Jul 17, 2021
d201f8a
Work through some test coverage
ahopkins Jul 17, 2021
7a59133
Passing tests
ahopkins Jul 18, 2021
6b546e5
Post linting
ahopkins Jul 18, 2021
32940f4
Setup proper resets
ahopkins Jul 18, 2021
7f7f880
Merge branch 'main' into signals
ahopkins Jul 18, 2021
43a5399
Update testing branch and merge from main
ahopkins Aug 1, 2021
00bb46f
coverage reporting
ahopkins Aug 1, 2021
9b8dfaa
Merge branch 'main' into signals
ahopkins Aug 4, 2021
bcbec02
Fixes from vltr comments
ahopkins Aug 5, 2021
8e891f7
Merge conflict resolution
ahopkins Aug 5, 2021
6b1be51
Merge branch 'signals' of github.com:sanic-org/sanic into signals
ahopkins Aug 5, 2021
836a661
clear delayed tasks
ahopkins Aug 5, 2021
dfabda6
Fix bad test
ahopkins Aug 5, 2021
fe4fbc7
rm pycache
ahopkins Aug 5, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 22 additions & 7 deletions examples/run_async_advanced.py
Original file line number Diff line number Diff line change
@@ -1,29 +1,44 @@
from sanic import Sanic
from sanic import response
from signal import signal, SIGINT
import asyncio

from signal import SIGINT, signal

import uvloop

from sanic import Sanic, response
from sanic.server import AsyncioServer


app = Sanic(__name__)

@app.listener('after_server_start')

@app.listener("after_server_start")
async def after_start_test(app, loop):
print("Async Server Started!")


@app.route("/")
async def test(request):
return response.json({"answer": "42"})


asyncio.set_event_loop(uvloop.new_event_loop())
serv_coro = app.create_server(host="0.0.0.0", port=8000, return_asyncio_server=True)
serv_coro = app.create_server(
host="0.0.0.0", port=8000, return_asyncio_server=True
)
loop = asyncio.get_event_loop()
serv_task = asyncio.ensure_future(serv_coro, loop=loop)
signal(SIGINT, lambda s, f: loop.stop())
server = loop.run_until_complete(serv_task)
server: AsyncioServer = loop.run_until_complete(serv_task) # type: ignore
server.startup()

# When using app.run(), this actually triggers before the serv_coro.
# But, in this example, we are using the convenience method, even if it is
# out of order.
server.before_start()
server.after_start()
try:
loop.run_forever()
except KeyboardInterrupt as e:
except KeyboardInterrupt:
loop.stop()
finally:
server.before_stop()
Expand Down
Loading