Я переключаю проект Python с 2.7.x на 3.7.x, работающий в Windows 10, и столкнулся с проблемой с FakeRedis.У меня есть класс RedisCache, который выглядит следующим образом:
class RedisCache(object):
def __init__(self, connection_info, is_testing):
if is_testing:
import fakeredis
self.conn = fakeredis.FakeStrictRedis()
else:
self.conn = redis.StrictRedis(host=connection_info['host'], port=connection_info['port'], db=0)
def get(self, key_name, default=None):
return self.conn.get(key_name)
При выполнении моих тестов соединение создается как экземпляр FakeStrictRedis, а затем при вызове get код в конечном итоге вызывает redis.SelectSelector.check_is_ready_for_command.», который затем вызывает« select.select », передавая экземпляр« fakeredis._server.FakeSocket ».
def check_is_ready_for_command(self, timeout):
"""
Return True if the socket is ready to send a command,
otherwise False.
"""
r, w, e = select.select([self.sock], [self.sock], [self.sock],
timeout)
return bool(w and not r and not e)
Затем я получаю следующий стек вызовов при вызове« select.select »:
\core\rediscache.py line 41, in get s = self.conn.get(key_name)
\env\lib\site-packages\redis\client.py line 1264, in get return self.execute_command(\'GET\', name)
\env\lib\site-packages\redis\client.py line 772, in execute_command connection = pool.get_connection(command_name, **options)
\env\lib\site-packages\redis\connection.py line 999, in get_connection if not connection.is_ready_for_command():
\env\lib\site-packages\redis\connection.py line 632, in is_ready_for_command return self._selector.is_ready_for_command()
\env\lib\site-packages\redis\selector.py line 43, in is_ready_for_command return self.check_is_ready_for_command(timeout)
\env\lib\site-packages\redis\selector.py line 104, in check_is_ready_for_command timeout)
TypeError: argument must be an int, or have a fileno() method.
Проблема в том, что в FakeSocket нет метода fileno (), поэтому неясно, как это должно работать.
Спасибо за любую помощь.