Skip to content

Commit

Permalink
fix gdpy3 broken logger with python 3.12.3
Browse files Browse the repository at this point in the history
* wait for python/cpython#119819

* temporarily fix error in gdpy3:

```
Process ForkPoolWorker-246:
Traceback (most recent call last):
  File "/usr/lib/python3.12/logging/config.py", line 581, in configure
    handler = self.configure_handler(handlers[name])
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/logging/config.py", line 801, in configure_handler
    raise TypeError('Invalid queue specifier %r' % qspec)
TypeError: Invalid queue specifier <AutoProxy[Queue] object, typeid 'Queue' at 0x7f43d2fee7e0>

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/lib/python3.12/multiprocessing/process.py", line 314, in _bootstrap
    self.run()
  File "/usr/lib/python3.12/multiprocessing/process.py", line 108, in run
    self._target(*self._args, **self._kwargs)
  File "/usr/lib/python3.12/multiprocessing/pool.py", line 109, in worker
    initializer(*initargs)
  File "/usr/lib/python3.12/site-packages/gdpy3/glogger.py", line 167, in __call__
    logging.config.dictConfig(self.glogger_config)
  File "/usr/lib/python3.12/logging/config.py", line 914, in dictConfig
    dictConfigClass(config).configure()
  File "/usr/lib/python3.12/logging/config.py", line 588, in configure
    raise ValueError('Unable to configure handler '
ValueError: Unable to configure handler 'queue'
```
  • Loading branch information
shmilee committed May 31, 2024
1 parent 89ae531 commit 9063eea
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,12 @@ def run(self):
'Operating System :: OS Independent',
'Operating System :: POSIX :: Linux',
'Programming Language :: Python :: 3 :: Only',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
'Programming Language :: Python :: 3.10',
'Programming Language :: Python :: 3.11',
'Programming Language :: Python :: 3.12',
'Topic :: Scientific/Engineering :: Physics',
'Topic :: Scientific/Engineering :: Visualization'
],
Expand Down
8 changes: 7 additions & 1 deletion src/glogger.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
'''

import os
import sys
import tempfile
import getpass
import time
Expand Down Expand Up @@ -148,12 +149,17 @@ def setConsoleLevel(level):

logging.setLoggerClass(GLogger)
logging.config.dictConfig(glogger_config_main)
Pyver_tuple = sys.version_info[:3]


class LogWorkInitializer(object):
def __init__(self, manager):
# listener in MainProcess
logqueue = manager.Queue(-1)
if (3, 12, 0) <= Pyver_tuple <= (3, 12, 3):
# https://github.com/python/cpython/issues/119819
logqueue = multiprocessing.Queue(-1)
else:
logqueue = manager.Queue(-1)
logging.config.dictConfig(glogger_config_listen)
global queue_listener
queue_listener = logging.handlers.QueueListener(
Expand Down

0 comments on commit 9063eea

Please sign in to comment.