Use uuid4 to generate id for Python3.5 Python3.4 Python2.7
This commit is contained in:
+6
-2
@@ -1,7 +1,11 @@
|
|||||||
import logging
|
import logging
|
||||||
import secrets
|
try:
|
||||||
|
import secrets
|
||||||
|
except ImportError:
|
||||||
|
secrets = None
|
||||||
import tornado.websocket
|
import tornado.websocket
|
||||||
|
|
||||||
|
from uuid import uuid4
|
||||||
from tornado.ioloop import IOLoop
|
from tornado.ioloop import IOLoop
|
||||||
from tornado.iostream import _ERRNO_CONNRESET
|
from tornado.iostream import _ERRNO_CONNRESET
|
||||||
from tornado.util import errno_from_exception
|
from tornado.util import errno_from_exception
|
||||||
@@ -53,7 +57,7 @@ class Worker(object):
|
|||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def gen_id(cls):
|
def gen_id(cls):
|
||||||
return secrets.token_urlsafe(nbytes=32)
|
return secrets.token_urlsafe(nbytes=32) if secrets else uuid4().hex
|
||||||
|
|
||||||
def set_handler(self, handler):
|
def set_handler(self, handler):
|
||||||
if not self.handler:
|
if not self.handler:
|
||||||
|
|||||||
Reference in New Issue
Block a user