2
2
3
3
import functools
4
4
import socket
5
+ from contextlib import asynccontextmanager
5
6
from typing import Optional
6
7
from unittest import mock
7
8
from unittest .mock import patch
18
19
from redis .typing import EncodableT
19
20
from redis .utils import HIREDIS_AVAILABLE
20
21
from tests .conftest import get_protocol_version , skip_if_server_version_lt
21
- from tests .test_asyncio .conftest import asynccontextmanager
22
22
23
23
pytestmark = pytest .mark .anyio
24
24
@@ -401,6 +401,7 @@ async def test_channel_sync_async_message_handler(self, r):
401
401
p = r .pubsub (ignore_subscribe_messages = True )
402
402
await p .subscribe (foo = self .message_handler )
403
403
await p .subscribe (bar = self .async_message_handler )
404
+ assert await wait_for_message (p ) is None
404
405
assert await r .publish ("foo" , "test message" ) == 1
405
406
assert await r .publish ("bar" , "test message 2" ) == 1
406
407
assert await wait_for_message (p ) is None
@@ -910,7 +911,6 @@ async def test_reconnect_socket_error(self, r: redis.Redis, method):
910
911
# it is in a disconnected state
911
912
912
913
# wait for reconnect
913
- print ("wait for reconnect" )
914
914
await wait_for_condition (
915
915
self .cond , lambda : self .pubsub .connection .is_connected
916
916
)
@@ -948,22 +948,14 @@ async def loop(
948
948
try :
949
949
if self .state == 4 :
950
950
break
951
- print ("loop: getting message" )
952
951
got_msg = await self .get_message ()
953
- print (f"{ got_msg = } { self .state = } " )
954
952
assert got_msg
955
953
if self .state in (1 , 2 ):
956
- print ("reconnected!" )
957
954
self .state = 3 # successful reconnect
958
955
except redis .ConnectionError :
959
956
assert self .state in (1 , 2 )
960
- print ("noticed disconnect" )
961
957
self .state = 2 # signal that we noticed the disconnect
962
- except BaseException as exc :
963
- print ("error while while getting message in loop():" , type (exc ))
964
- raise
965
958
finally :
966
- print ("notifying condition" )
967
959
self .cond .notify ()
968
960
# make sure that we did notice the connection error
969
961
# or reconnected without any error
@@ -972,13 +964,9 @@ async def loop(
972
964
973
965
async def loop_step_get_message (self , send : MemoryObjectSendStream ) -> bool :
974
966
# get a single message via get_message
975
- print ("getting message" )
976
967
message = await self .pubsub .get_message (timeout = 0.1 )
977
- print (f" result: { message } { self .state = } " )
978
968
if message is not None :
979
- print (" sending message" )
980
969
await send .send (message )
981
- print (" sent message" )
982
970
return True
983
971
return False
984
972
0 commit comments