我正在尝试通过使用rq和redis完成任务。但是,导入模块有时会遇到困难。
JobTimeoutException: Task exceeded maximum timeout value (100 seconds)
File "rq/worker.py", line 812, in perform_job
rv = job.perform()
File "rq/job.py", line 588, in perform
self._result = self._execute()
File "rq/job.py", line 594, in _execute
return self.func(*self.args, **self.kwargs)
File "rq/job.py", line 199, in func
return import_attribute(self.func_name)
File "rq/utils.py", line 155, in import_attribute
module = importlib.import_module(module_name)
File "__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 994, in _gcd_import
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 678, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "my_task.py", line 13, in <module>
import my_sockets
File "my_sockets.py", line 1, in <module>
from flask_socketio import SocketIO
File "__init__.py", line 8, in <module>
from socketio import socketio_manage
File "__init__.py", line 3, in <module>
from .client import Client
File "/usr/local/lib/python3.6/dist-packages/socketio/client.py", line 5, in <module>
import engineio
File "__init__.py", line 3, in <module>
from .client import Client
File "/usr/local/lib/python3.6/dist-packages/engineio/client.py", line 13, in <module>
import requests
File "__init__.py", line 95, in <module>
from urllib3.contrib import pyopenssl
File "urllib3/contrib/pyopenssl.py", line 48, in <module>
from cryptography.hazmat.backends.openssl import backend as openssl_backend
File "cryptography/hazmat/backends/openssl/__init__.py", line 7, in <module>
from cryptography.hazmat.backends.openssl.backend import backend
File "cryptography/hazmat/backends/openssl/backend.py", line 2419, in <module>
backend = Backend()
File "cryptography/hazmat/backends/openssl/backend.py", line 119, in __init__
self.activate_osrandom_engine()
File "cryptography/hazmat/backends/openssl/backend.py", line 163, in activate_osrandom_engine
with self._get_osurandom_engine() as e:
File "contextlib.py", line 81, in __enter__
return next(self.gen)
File "cryptography/hazmat/backends/openssl/backend.py", line 146, in _get_osurandom_engine
res = self._lib.ENGINE_init(e)
File "rq/timeouts.py", line 64, in handle_death_penalty
'({0} seconds)'.format(self._timeout))
10次中只有1次发生,这使其难以复制。有谁知道是什么原因造成的?