-
-
Notifications
You must be signed in to change notification settings - Fork 222
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
Pickling Error when using 20.2.0 release with multiprocessing Pool #301
Comments
The problem is that the default logger changed as called out in https://github.com/hynek/structlog/blob/master/CHANGELOG.rst#backward-incompatible-changes-1 I will look into making the new one pickleable without compromising on its performance, but you can have the old behavior by passing |
I believe this has been fixed by 334f029. Ping this issue if not, thanks. |
I have a similar issue on 21.1.0 when Example code below: import asyncio
from concurrent.futures.process import ProcessPoolExecutor
import structlog
structlog.configure(
# cache_logger_on_first_use=True # uncomment to get an error
)
class TestClass:
def __init__(self):
self.logger = structlog.get_logger('test')
def sync_method(self):
self.logger.info('Hello from sync_method', val=1)
async def main(self):
self.logger.info('Hello from main')
loop = asyncio.get_running_loop()
with ProcessPoolExecutor() as pool:
await loop.run_in_executor(pool, self.sync_method)
if __name__ == '__main__':
print(structlog.__version__)
test_class = TestClass()
asyncio.run(test_class.main()) |
I'm afraid that can't be fixed unless you find a way to pickle finalized_bind. AFAICT your options are:
Barring any logging hot loops, so suspect the second option is good enough. |
After upgrading structlog version from 20.1.0 to 20.2.0 i started getting errors when calling function that somehow uses logs, in parallel, using multiprocessing Pool.
Environment: python 3.7, structlog 20.2.0
Example Code:
Expected output(as with structlog 20.1.0):
Actual output(with structlog 20.2.0):
The text was updated successfully, but these errors were encountered: