Skip to content

Supervisor win higher version Chinese garbled code #49

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wssf812 opened this issue Aug 9, 2023 · 4 comments
Open

Supervisor win higher version Chinese garbled code #49

wssf812 opened this issue Aug 9, 2023 · 4 comments

Comments

@wssf812
Copy link

wssf812 commented Aug 9, 2023

Supervisor-win higher version Chinese garbled code,the version used is 4.7.0.
Under 4.5.0, there will be no garbled code,Why is this?
Error info: дredis{'name': 'Ա', 'user_id': 22}

@alexsilva
Copy link
Owner

@wssf812 Do you have any configuration examples and how to reproduce this failure? I don't fully understand what problem you are facing.

@wssf812
Copy link
Author

wssf812 commented Aug 9, 2023

@wssf812 Do you have any configuration examples and how to reproduce this failure? I don't fully understand what problem you are facing.

To reproduce simply add Chinese logs to the backend service
This is my configuration file:
[inet_http_server]
port=127.0.0.1:9001

[supervisorctl]
serverurl=http://127.0.0.1:9001

[supervisord]
logfile=D:\flexibleline_backend\supervisor\log\supervisord.log
pidfile=D:\flexibleline_backend\supervisor\pid\supervisord.pid
loglevel=info

[program:flexibleline_api]
command=cmd.exe /K "conda activate flex_line_env && cd /d D:\flexibleline_backend && python main.py"
autostart=true
autorestart=true
startretries=3
stdout_logfile=D:\flexibleline_backend\supervisor\log\flexibleline_api_err.log
stderr_logfile=D:\flexibleline_backend\supervisor\log\flexibleline_api_err.log

[rpcinterface:supervisor]
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface

The problem I encountered was that there was garbled code when writing Chinese logs in version 4.7.0, but switching to version 4.5.0 was no problem. After checking your source code, I found that the difference between the two was due to the issue with win.WriteFile, where the encoding was not specified.

This is just my speculation, but from the perspective of the issue, it should be a coding exception caused by a higher version of the program. It may be a problem with the window plugin, a bug on your code, or a coding issue itself. I hope you can take a look and give me a response. Thank you

@alexsilva
Copy link
Owner

The default encoding used is utf8 and this encoding is used to convert any byte to string. The Chinese language may not be able to convert some characters. The default behavior is to ignore such characters so as not to critically fail.

Ouput stream read

@wssf812
Copy link
Author

wssf812 commented Aug 10, 2023

The default encoding used is utf8 and this encoding is used to convert any byte to string. The Chinese language may not be able to convert some characters. The default behavior is to ignore such characters so as not to critically fail.

Ouput stream read

Why is version 4.5.0 possible? I see that the address code corresponding to version 4.5.0 of the connection you sent is as follows, and there is also an error in ignoring it. I am a bit confused
4.5.0 code:
def handle_read_event(self):
data = self.process.config.options.readfd(self.fd)
if data is not None: # empty queue
self.output_buffer += as_bytes(data, ignore=True)
self.record_output()
if not data:
# if we get no data back from the pipe, it means that the
# child process has ended. See
# mail.python.org/pipermail/python-dev/2004-August/046850.html
self.close()

4.5.0 as_bytes function
def as_bytes(s, encoding='utf-8', ignore=False):
return _Stream(s, bytes).encode(encoding=encoding, ignore=ignore)

Please refer to the code similar to yours in version 4.5.0 above, which also includes' ignore 'as' true'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants