Closed PythonTryHard closed 1 year ago
Hi. Thanks for the report. I think it's a duplicate of #342. I will fix it in the next few days.
Ah, I did see the issue you linked while searching. I saw that it was about ctypes so I ignored it from a glance. I'm commuting so I'll try the workarounds later. Thank you for the pointer!
@Delgan Life got in the way, my apologies for not responding.
I had a glance at #342 and while the cause is similar (something went wrong in the pickling because my code is pickling a ), I couldn't wrap my head fully around the workaround proposed there. But, I saw the idea of manually filtering out the exceptions and deal with it manually. With that, I stuck a debugger to my reproduction code to see the flow of the record that's causing the exception chain: And it missed the InterceptHandler
completely. So now I'm clueless and how to proceed.
You can do something like that, the idea is just to remove the Exception
which can't be pickled when enqueue=True
:
import hikari.errors
def fixup_pickle_error(record):
if record["exception"] is not None and isinstance(record["exception"].value, hikari.errors.UnauthorizedError):
record["exception"] = record["exception"]._replace(value=None)
return True
logger.remove()
logger.add(sys.stderr, level="INFO", enqueue=True, filter=fixup_pickle_error)
This should be fixed by #905 and will be available in the next release. I'm closing this ticket consequently.
Python version: 3.10.8, manually compiled with
--enable-optimizations --with-lto
using GCC 11.3.0 againstglibc
2.25. Loguru version:0.6.0
, installed from PyPI OS information: KDE Neon 5.27 (based on Ubuntu 22.04.1 LTS), fully up-to-date Development environment: Python 3.10.8 underpoetry
Minimal reproduction
log.py
main.py
Instruction to run
main.py
throws exception, loguru writes exception tostderr
main.py
throws exception,loguru
throws exceptions (redacted the record for brevity and potentially sensitive information):During handling of the above exception, another exception occurred:
Traceback (most recent call last): File "/home/f4ll3n53r4ph/.env/opereta-ds2j3CUa-py3.10/lib/python3.10/site-packages/loguru/_handler.py", line 175, in emit self._queue.put(str_record) File "/opt/python-3.10.8/lib/python3.10/multiprocessing/queues.py", line 371, in put obj = _ForkingPickler.dumps(obj) File "/opt/python-3.10.8/lib/python3.10/multiprocessing/reduction.py", line 51, in dumps cls(buf, protocol).dump(obj) File "/home/f4ll3n53r4ph/.env/opereta-ds2j3CUa-py3.10/lib/python3.10/site-packages/loguru/_recattrs.py", line 73, in reduce pickle.dumps(self.value) TypeError: can't pickle multidict._multidict.CIMultiDictProxy objects --- End of logging error ---