From 9a7cfe767c45ec621e8ea7f0d3233251bb12c781 Mon Sep 17 00:00:00 2001 From: Sheng Date: Mon, 21 Nov 2022 14:32:41 +0800 Subject: [PATCH] Use uuid4 to generate id for Python3.5 Python3.4 Python2.7 --- webssh/worker.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/webssh/worker.py b/webssh/worker.py index 91e05bd..130e53a 100644 --- a/webssh/worker.py +++ b/webssh/worker.py @@ -1,7 +1,11 @@ import logging -import secrets +try: + import secrets +except ImportError: + secrets = None import tornado.websocket +from uuid import uuid4 from tornado.ioloop import IOLoop from tornado.iostream import _ERRNO_CONNRESET from tornado.util import errno_from_exception @@ -53,7 +57,7 @@ class Worker(object): @classmethod 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): if not self.handler: