mirror of
https://github.com/sprockets/sprockets.http.git
synced 2024-11-14 11:19:26 +00:00
Deprecation notice for sprockets.http.run.
sprockets.http.run will only accept sprockets.app.Application instances in the near future. I'm doing this so that we can clean up the runner code significantly as we move to using `async` and `await` instead of futures.
This commit is contained in:
parent
9430941e4a
commit
5c103cde0e
3 changed files with 25 additions and 2 deletions
|
@ -3,10 +3,12 @@
|
|||
Release History
|
||||
===============
|
||||
|
||||
Next release
|
||||
------------
|
||||
`Next release`_
|
||||
---------------
|
||||
- Updated to support Python 3.9. ``asyncio.Task.all_tasks`` was removed
|
||||
so I switched to ``asyncio.all_tasks`` if it exists.
|
||||
- Deprecate calling ``sprockets.http.run`` with anything that isn't a
|
||||
``sprockets.app.Application`` instance.
|
||||
|
||||
`2.1.1`_ (19 Feb 2020)
|
||||
----------------------
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import asyncio
|
||||
import logging
|
||||
import sys
|
||||
import warnings
|
||||
|
||||
from tornado import concurrent, web
|
||||
|
||||
|
@ -260,6 +261,11 @@ def wrap_application(application, before_run, on_start, shutdown):
|
|||
shutdown = [] if shutdown is None else shutdown
|
||||
|
||||
if not isinstance(application, Application):
|
||||
warnings.warn(
|
||||
'sprockets.http.run is only going to accept '
|
||||
'sprockets.app.Application instances in 3.0, '
|
||||
'was called with {}'.format(type(application).__name__),
|
||||
category=DeprecationWarning)
|
||||
application = _ApplicationAdapter(application)
|
||||
|
||||
application.before_run_callbacks.extend(before_run)
|
||||
|
|
15
tests.py
15
tests.py
|
@ -469,6 +469,21 @@ class RunnerTests(MockHelper, unittest.TestCase):
|
|||
self.io_loop.stop.assert_called_once_with()
|
||||
self.assertNotEqual(self.io_loop._timeouts, [])
|
||||
|
||||
def test_that_calling_with_non_sprockets_application_is_deprecated(self):
|
||||
with warnings.catch_warnings(record=True) as captured:
|
||||
warnings.filterwarnings(action='always', module='sprockets')
|
||||
sprockets.http.runner.Runner(web.Application())
|
||||
for warning in captured:
|
||||
if 'sprockets.app.Application' in str(warning.message):
|
||||
break
|
||||
else:
|
||||
self.fail('expected deprecation warning from runnr.Runner')
|
||||
|
||||
with warnings.catch_warnings(record=True) as captured:
|
||||
warnings.filterwarnings(action='always', module='sprockets')
|
||||
sprockets.http.runner.Runner(sprockets.http.app.Application())
|
||||
self.assertEqual(len(captured), 0)
|
||||
|
||||
|
||||
class AsyncRunTests(unittest.TestCase):
|
||||
|
||||
|
|
Loading…
Reference in a new issue