Open
Conversation
2. use default multiprocessing process start method to use fork mode on linux;
frankang
reviewed
Dec 9, 2022
| return pickle.loads(message["data"]) | ||
| except RedisError as e: | ||
| logger.warning('recv_response: redis error occurs in get_message, {}', str(e)) | ||
| self._setup() # 重新订阅 |
There was a problem hiding this comment.
There might be an issue here. self._setup() fails when redis server is stopped, but when redis server restarts, this self._setup() usually will not get executed because the above try: entry now returns with no error.
Suggested change
| self._setup() # 重新订阅 | |
| while True: | |
| try: | |
| self._redis.ping() | |
| self._setup() # 重新订阅 | |
| break | |
| except RedisError as e: | |
| time.sleep(0.2) |
There was a problem hiding this comment.
I find that completely removal of the self._setup() part in the error handling step also works. It looks like redis-py recovers the connection and the previously subscribed channel after the failure.
If the _setup() is executed and erred during the redis-server's downtime, then redis-py cannot recover previous subscription anymore.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
fix redis worker hang when redis connection is lost or redis server is restarted. When redis server is restarted, the collect thread in original service streamer will exit;
fix redis subscribe channel lost when redis subscribe connection receive no message for a long time. Add health check for get_messsage api.
remove the requirement that redis server subscribes all channels.