Skip to content
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

Add "reinstall()" method to make it easier in spawn multiprocessing #1069

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

monchin
Copy link

@monchin monchin commented Jan 20, 2024

Make it easier when using loguru in spawn multiprocessing environment

@monchin
Copy link
Author

monchin commented Jan 20, 2024

It seems black does not check docstring's length.

@Delgan
Copy link
Owner

Delgan commented Jan 21, 2024

Thanks for the PR @monchin!

However, I'm going to wait a little before merging it, because there are quite a few special cases I'd like to think about and a lot of unit tests that need to be implemented. I'll probably make some commits after yours to complete the development, if you're OK with that.

It seems black does not check docstring's length.

Indeed, docstrings are not automatically formatted by black, we have to do it manually.

loguru/_logger.py Outdated Show resolved Hide resolved
loguru/_logger.py Outdated Show resolved Hide resolved
tests/test_multiprocessing.py Outdated Show resolved Hide resolved
loguru/_logger.py Outdated Show resolved Hide resolved
@monchin
Copy link
Author

monchin commented Jan 22, 2024

I'm not familiar with ruff, seems it failed because I created a new tests/test_reinstall.py file

@Delgan
Copy link
Owner

Delgan commented Jan 22, 2024

Thanks for the update.

I'm not familiar with ruff, seems it failed because I created a new tests/test_reinstall.py file

Similarly to black, the ruff tool notably replaces isort and is in charge of re-ordering the import statements.

You can try to install the pre-commit hooks to automatically fix your files before git commit:

$ pre-commit install --install-hooks

Or you can manually fix the file with:

$ ruff tests/test_reinstall.py --fix

@indigoviolet
Copy link

@Delgan What is the status of this? this would be a really nice addition to have.

gjhami added a commit to gjhami/LinkSiren that referenced this pull request Oct 31, 2024
Add multiprocessing functionality. However, this conflicts with wriring text to stdout other than a progressbar. Ideally, loguru could be used to manage logs in a multi-process safe way, but this requires a somewhat hacky solution of passing an attribute of the parent logger object into each spawned process and manually setting the logger imported in the spawned process to use the attribute passed as a paremeter. There is a [PR](Delgan/loguru#1069) to create a new function called reinstall() that would address this, but it has yet to be merged. Until the PR is merged, using multithreading instead of multiprocessing seems like the better solution.
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

Successfully merging this pull request may close these issues.

3 participants