mirror of
https://github.com/django/daphne.git
synced 2025-08-03 10:00:09 +03:00
sort imports and add some commentary to cancellederror test
This commit is contained in:
parent
49c00da715
commit
af16649725
|
@ -6,9 +6,10 @@ from urllib import parse
|
||||||
|
|
||||||
import http_strategies
|
import http_strategies
|
||||||
from http_base import DaphneTestCase, DaphneTestingInstance
|
from http_base import DaphneTestCase, DaphneTestingInstance
|
||||||
from daphne.testing import BaseDaphneTestingInstance
|
|
||||||
from hypothesis import given, settings
|
from hypothesis import given, settings
|
||||||
|
|
||||||
|
from daphne.testing import BaseDaphneTestingInstance
|
||||||
|
|
||||||
|
|
||||||
class TestWebsocket(DaphneTestCase):
|
class TestWebsocket(DaphneTestCase):
|
||||||
"""
|
"""
|
||||||
|
@ -285,8 +286,10 @@ class TestWebsocket(DaphneTestCase):
|
||||||
|
|
||||||
async def cancelling_application(scope, receive, send):
|
async def cancelling_application(scope, receive, send):
|
||||||
import asyncio
|
import asyncio
|
||||||
|
|
||||||
from twisted.internet import reactor
|
from twisted.internet import reactor
|
||||||
|
|
||||||
|
# Stop the server after a short delay so that the teardown is run.
|
||||||
reactor.callLater(2, lambda: reactor.stop())
|
reactor.callLater(2, lambda: reactor.stop())
|
||||||
await send({"type": "websocket.accept"})
|
await send({"type": "websocket.accept"})
|
||||||
raise asyncio.CancelledError()
|
raise asyncio.CancelledError()
|
||||||
|
@ -303,6 +306,11 @@ class CancellingTestingInstance(BaseDaphneTestingInstance):
|
||||||
def process_teardown(self):
|
def process_teardown(self):
|
||||||
import multiprocessing
|
import multiprocessing
|
||||||
|
|
||||||
|
# Get a hold of the enclosing DaphneProcess (we're currently running in
|
||||||
|
# the same process as the application).
|
||||||
proc = multiprocessing.current_process()
|
proc = multiprocessing.current_process()
|
||||||
|
# By now the (only) socket should have disconnected, and the
|
||||||
|
# application_checker should have run. If there are any connections
|
||||||
|
# still, it means that the application_checker did not clean them up.
|
||||||
if proc.server.connections:
|
if proc.server.connections:
|
||||||
raise ConnectionsNotEmpty()
|
raise ConnectionsNotEmpty()
|
||||||
|
|
Loading…
Reference in New Issue
Block a user