🚨 Get rid of some deprecation warnings
There are still more to fix however, caused by IOLoop() and IOLoop.current in Tornado getting deprecated.
This commit is contained in:
1 parent
e68c075df8
commit
acbd1efd26
5 files changed
+33
-18
No files matched your search
@@ -665,7 +665,9 @@ class Server:
|
||||
|
||||
## Tornado initialization starts here
|
||||
|
||||
ioloop = IOLoop()
|
||||
ioloop = (
|
||||
IOLoop()
|
||||
) # TODO: This way to create the ioloop is deprecated and logs a warning
|
||||
ioloop.install()
|
||||
|
||||
enable_cors = settings().getBoolean(["api", "allowCrossOrigin"])
|
||||
|
||||
+7
-6
@@ -8,20 +8,20 @@ from __future__ import absolute_import, division, print_function, unicode_litera
|
||||
SockJS session implementation.
|
||||
"""
|
||||
|
||||
import logging
|
||||
import asyncio
|
||||
import functools
|
||||
import logging
|
||||
|
||||
from octoprint.vendor.sockjs.tornado import sessioncontainer, periodic, proto
|
||||
from octoprint.vendor.sockjs.tornado.util import bytes_to_str
|
||||
|
||||
from tornado.ioloop import IOLoop
|
||||
from octoprint.vendor.sockjs.tornado import periodic, proto, sessioncontainer
|
||||
from octoprint.vendor.sockjs.tornado.util import bytes_to_str, get_current_ioloop
|
||||
|
||||
LOG = logging.getLogger("tornado.general")
|
||||
|
||||
|
||||
def ensure_io_loop(method):
|
||||
@functools.wraps(method)
|
||||
def wrapper(self, *args, **kwargs):
|
||||
if IOLoop.current(False):
|
||||
if get_current_ioloop():
|
||||
method(self, *args, **kwargs)
|
||||
else:
|
||||
def run():
|
||||
@@ -29,6 +29,7 @@ def ensure_io_loop(method):
|
||||
self.server.io_loop.add_callback(run)
|
||||
return wrapper
|
||||
|
||||
|
||||
class ConnectionInfo(object):
|
||||
"""Connection information object.
|
||||
|
||||
|
||||
@@ -8,12 +8,12 @@ from __future__ import absolute_import, division, print_function, unicode_litera
|
||||
Raw websocket transport implementation
|
||||
"""
|
||||
import logging
|
||||
import socket
|
||||
|
||||
from octoprint.vendor.sockjs.tornado import websocket, session
|
||||
from octoprint.vendor.sockjs.tornado.transports import base
|
||||
from tornado.websocket import WebSocketError
|
||||
from tornado.ioloop import IOLoop
|
||||
|
||||
from octoprint.vendor.sockjs.tornado import session, websocket
|
||||
from octoprint.vendor.sockjs.tornado.transports import base
|
||||
from octoprint.vendor.sockjs.tornado.util import get_current_ioloop
|
||||
|
||||
LOG = logging.getLogger("tornado.general")
|
||||
|
||||
@@ -78,7 +78,7 @@ class RawWebSocketTransport(websocket.SockJSWebSocketHandler, base.BaseTransport
|
||||
session.close()
|
||||
|
||||
def send_pack(self, message, binary=False):
|
||||
if IOLoop.current(False) == self.server.io_loop:
|
||||
if get_current_ioloop() == self.server.io_loop:
|
||||
# Running in Main Thread
|
||||
# Send message
|
||||
try:
|
||||
|
||||
@@ -8,13 +8,12 @@ from __future__ import absolute_import, division, print_function, unicode_litera
|
||||
Websocket transport implementation
|
||||
"""
|
||||
import logging
|
||||
import socket
|
||||
|
||||
from tornado.websocket import WebSocketError
|
||||
|
||||
from octoprint.vendor.sockjs.tornado import proto, websocket
|
||||
from octoprint.vendor.sockjs.tornado.transports import base
|
||||
from octoprint.vendor.sockjs.tornado.util import bytes_to_str
|
||||
from tornado.websocket import WebSocketError
|
||||
from tornado.ioloop import IOLoop
|
||||
from octoprint.vendor.sockjs.tornado.util import bytes_to_str, get_current_ioloop
|
||||
|
||||
LOG = logging.getLogger("tornado.general")
|
||||
|
||||
@@ -88,7 +87,7 @@ class WebSocketTransport(websocket.SockJSWebSocketHandler, base.BaseTransportMix
|
||||
session.close()
|
||||
|
||||
def send_pack(self, message, binary=False):
|
||||
if IOLoop.current(False) == self.server.io_loop:
|
||||
if get_current_ioloop() == self.server.io_loop:
|
||||
# Running in Main Thread
|
||||
# Send message
|
||||
try:
|
||||
|
||||
+14
-1
@@ -1,8 +1,8 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import absolute_import, division, print_function, unicode_literals
|
||||
|
||||
import sys
|
||||
import functools
|
||||
import sys
|
||||
|
||||
PY3 = sys.version_info[0] == 3
|
||||
|
||||
@@ -61,3 +61,16 @@ def no_auto_finish(method):
|
||||
self._auto_finish = False
|
||||
return method(self, *args, **kwargs)
|
||||
return wrapper
|
||||
|
||||
def get_current_ioloop():
|
||||
import asyncio
|
||||
|
||||
from tornado.ioloop import IOLoop
|
||||
|
||||
try:
|
||||
loop = asyncio.get_running_loop()
|
||||
return IOLoop._ioloop_for_asyncio.get(loop)
|
||||
except RuntimeError:
|
||||
# no current loop
|
||||
return None
|
||||
|
||||
Reference in new issue
Block a user